Click here to Skip to main content
15,891,943 members
Home / Discussions / Java
   

Java

 
Questionjava Pin
Member 1402833822-Oct-18 4:12
Member 1402833822-Oct-18 4:12 
AnswerRe: java Pin
Richard MacCutchan22-Oct-18 5:55
mveRichard MacCutchan22-Oct-18 5:55 
GeneralRe: java Pin
Member 1402833822-Oct-18 6:56
Member 1402833822-Oct-18 6:56 
GeneralRe: java Pin
Richard MacCutchan22-Oct-18 8:42
mveRichard MacCutchan22-Oct-18 8:42 
GeneralRe: java. Troll Pin
Mycroft Holmes22-Oct-18 13:02
professionalMycroft Holmes22-Oct-18 13:02 
QuestionRuntime Error showing NumberFormatException: Kindly solve the error Pin
Member 1402130020-Oct-18 3:07
Member 1402130020-Oct-18 3:07 
QuestionRe: Runtime Error showing NumberFormatException: Kindly solve the error Pin
Richard MacCutchan20-Oct-18 4:05
mveRichard MacCutchan20-Oct-18 4:05 
AnswerRe: Runtime Error showing NumberFormatException: Kindly solve the error Pin
Afzaal Ahmad Zeeshan20-Oct-18 4:29
professionalAfzaal Ahmad Zeeshan20-Oct-18 4:29 
This error occurs when you input an argument to a function that has to convert the types of the data, such as in your case, from String to integer. To actually understand the problem do this simple thing, remove the throws Exception from the signature of the methods,
Java
void solve() throws Exception
This will lead you to the function that is most likely to throw the NumberFormatException (which is derived from Exception), and it will lead you to the function call,
Java
int n=Integer.parseInt(b.readLine());
The problem here is that the number that you are trying to input is not a valid number. I would rewrite the code in this way,
Java
try {
   int n = Integer.parseInt(b.readLine());

   // ... further down
} catch (NumberFormatException exception) {
   System.out.println("The input is invalid for this program to continue.");
} catch (Exception error) {
   System.out.println("Unhandled error has occurred, information provided: " + error.getMessage());
}
Remember, there is nothing that you can do to overcome this error, other than politely asking the user to enter the correct format of the number. This exception tells you that the number cannot be converted to that type—Integer. This means, that the number you are trying to input is correct, yet the NumberFormatException happens, the reason is that your number might be bigger than the MAX_VALUE for Integer type. Try using Long.parseLong(), or another type for the data that is overflowing.

Just for thought, read this as well, java - Integer.parseInt number format exception? - Stack Overflow

Number (Java Platform SE 7 )
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~

QuestionFinalize method in java Pin
ashutoshgadgil16-Oct-18 18:16
ashutoshgadgil16-Oct-18 18:16 
QuestionRe: Finalize method in java Pin
Richard MacCutchan16-Oct-18 21:57
mveRichard MacCutchan16-Oct-18 21:57 
AnswerRe: Finalize method in java Pin
ashutoshgadgil16-Oct-18 22:29
ashutoshgadgil16-Oct-18 22:29 
GeneralRe: Finalize method in java Pin
Richard MacCutchan16-Oct-18 23:07
mveRichard MacCutchan16-Oct-18 23:07 
GeneralRe: Finalize method in java Pin
ashutoshgadgil16-Oct-18 23:11
ashutoshgadgil16-Oct-18 23:11 
QuestionInspecting java application (Java spy, Java object inspector) - Automation Pin
Member 1383827315-Oct-18 18:58
Member 1383827315-Oct-18 18:58 
RantJava, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
nated09913-Oct-18 18:41
nated09913-Oct-18 18:41 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
Richard MacCutchan14-Oct-18 1:35
mveRichard MacCutchan14-Oct-18 1:35 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
#realJSOP5-Nov-18 4:27
mve#realJSOP5-Nov-18 4:27 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
nated09927-Dec-18 8:27
nated09927-Dec-18 8:27 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
Mycroft Holmes14-Oct-18 13:12
professionalMycroft Holmes14-Oct-18 13:12 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
Eddy Vluggen15-Oct-18 0:53
professionalEddy Vluggen15-Oct-18 0:53 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
#realJSOP5-Nov-18 4:33
mve#realJSOP5-Nov-18 4:33 
QuestionDaemon Thread Pin
ashutoshgadgil11-Oct-18 21:50
ashutoshgadgil11-Oct-18 21:50 
AnswerRe: Daemon Thread Pin
Richard MacCutchan11-Oct-18 22:34
mveRichard MacCutchan11-Oct-18 22:34 
QuestionJava SE 8 OCA Exam Pin
Willem Voigt9-Oct-18 1:34
Willem Voigt9-Oct-18 1:34 
AnswerRe: Java SE 8 OCA Exam Pin
Richard MacCutchan9-Oct-18 5:29
mveRichard MacCutchan9-Oct-18 5:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.