Computer Applications
Find the error :
double n2 = Double.parseDouble("2");
double n3 = Double.parseDouble("OCA");
System.out.println(n2 + " " + n3);
Java Library Classes
4 Likes
Answer
double n3 = Double.parseDouble("OCA");
statement will generate NumberFormatException at the time of conversion of String argument "OCA"
to double data type. The exception is raised because "OCA" is not a valid string representation of a numeric value, therefore it cannot be converted to Integer object.
Answered By
3 Likes
Related Questions
Predict the output.
int res = Integer.valueOf("100").compareTo(new Integer(100)); System.out.println(res);
Find the error:
Integer obj = new Integer("A"); System.out.println(obj);
Predict the output :
double n1 = Double.parseDouble("8.0"); double n2 = Double.parseDouble("2"); System.out.println(n1 + " " + n2);
What important is automatically happening in following code ?
long a = 124235L; Long b = new Long(a); long c = b.longValue(); System.out.println(c);