Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.base/java.lang.NumberFormatException.forInputString(Unknown Source) at java.base/java.lang.Integer.parseInt(Unknown Source) at java.base/java.lang.Integer.parseInt(Unknown Source) at rew.Project7's 1.main (Project7's 1.java:29)
if(n==1) { System.out.println ("Enter Account Number: "); String x = sc.nextLine(); x = x.replaceAll("-",""); accountNumber = Integer.parseInt(x); //Convert String to Numeric
It's the 29th line. The one on the top. It's about the error on the top. What's wrong with that? The accountNumber is declared int above.
java
public class Test {
public static void main(String[] args) {
String str = "";
int i = Integer.parseInt(str);
System.out.println(i);
}
}
Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:592) at java.lang.Integer.parseInt(Integer.java:615) at Test.main(Test.java:7)
Since you designed it yourself, wouldn't it be blank? Please print out the value of x.
It looks like x is blank. Check the space
© 2024 OneMinuteCode. All rights reserved.