Back
Can anyone help me how I can able to figure it out that a number is double or not? I am using this syntax:
if ( typeof ( items.elementAt(1) )== Double ) { sum.add( i, items.elementAt(1));}
if ( typeof ( items.elementAt(1) )== Double ) {
sum.add( i, items.elementAt(1));
}
How can I make it work properly?
You can try with this code:
if (items.elementAt(1) instanceof Double) { sum.add( i, items.elementAt(1));}
if (items.elementAt(1) instanceof Double) {
I hope this will help.
Want to become a Java expert? join Java Training now!!
31k questions
32.8k answers
501 comments
693 users