I get a Followed as error output I can understand how I can solve this error I use Output 1x input is omitted from the above code. Who makes it: Your problem is that the next length () reads the next long number of calls, but not the new line after that. Therefore, when you call the next line, you get the blank line back from the end of the number, as long as you read up to the new line. For example, if I do this: ... and 42 and 63; I will be printed: NumberFormatException
when I get a call for integer
input after long
input, here is my code snippet
System.out.print ("Student ID:"); StudentID = sc.nextLong (); System.out.print ("Student Number:"); StudName = integer Paracetrain (s. Nxtine ());
There are exceptions in the thread "main" java.lang.NumberFormatException: for input string: "" student name : Java in .lang.NumberFormatException.forInputString at java.lang.Integer.parseInt (Integer.javaitter92) (NumberFormatException.java:65) java.lang.Integer.parseInt (Integer.java:615) student.StudentClient.main On (StudentClient.java:68) Java Results:? 1
sc.nextInt ()
Instead, at the beginning of my code:
System.out.println ("\ nMENU 1-QUIT / 2-ADD Student"); Option = option = sc.nextInt (); If (option == 1) {System.exit (0); } If (option == 2) {studentIndex ++; Student list [studentIndex] = new student (); System.out.print ("Student Title (Mr. / Mrs.):"); StudentTitle = sc.nextLine (); System.out.print ("Student First Name:"); First name = sc.nextLine ();
Student Title: Student First Name:
System.out.println ("'+ sc.nextLong () +"' '); System.out.println ("'" + Sc.nextLine () + "''); Enter the numbers like System.out.println ("'" + sc.nextLine () + "' ');
Friday, 15 February 2013
java - NumberFormatException on Integer input after previous Long input -
class < After making a call for the first
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment