[Solved] can anyone solve my java codes? i can’t enter input for the second names..what should i do? [closed]


Your issue can be found in the method student_Names; instead of:

studentNames[x] = input.nextLine();

Use

if(x>0) input.nextLine();
studentNames[x] = input.nextLine();

Your issue comes from Java mistakingly believing that the user has already given the input for the next name; input.nextLine(); basically takes this input and throws it away, returning things back to their natural state.

Since name input works fine for the first student, however, the if(x>0) statement is necessary to make this apply only to the rest of the student names.

2

solved can anyone solve my java codes? i can’t enter input for the second names..what should i do? [closed]