Answer to Question #63033 in Java | JSP | JSF for mike

Question #63033
Exception in thread "main" java.lang.NumberFormatException: For input string: "J"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
at bear.read(bear.java:34)
at bear.main(bear.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
1
Expert's answer
2016-11-01T16:01:09-0400
The Integer.parseInt(String s) method works normally only with string representation of integers without spaces and indents. When this method takes incorrect argument, it will throw NumberFormatException.
For example:
Integer.parseInt(“123”); - correct, will return 123;
Integer.parseInt(“one”); - incorrect, will throw NumberFormatException.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS