1
    System.out.println("Please enter the number of students in the class: ");
    int numberOfStudents = console.nextInt();


    String [] studentName = new String [numberOfStudents]; 

    for (int i=0; i<studentName.length; i++)
    {

    System.out.println("Enter the name of student " + (i+1) + " in your class. ");
    studentName[i] = console.nextLine();
    System.out.println("Student name entered: " + studentName[i] + " \n");
    }

To avoid clutter from my last question. Anyway, the code works fine. But it skips the first student and leaves it blank it seems.

Leoinu
  • 91
  • 1
  • 4
  • 16
  • You can also read this: [Using nextInt() before nextLine()](http://christprogramming.wordpress.com/2014/01/30/java-common-mistakes-1/) – Christian Apr 19 '14 at 20:58
  • Read over both links. Thank you both very much! Helped this beginner in coding learn a even more! – Leoinu Apr 19 '14 at 21:02
  • BTW this problem affects all [nextXXX methods from Scanner](http://stackoverflow.com/questions/7056749/scanner-issue-when-using-nextline-after-nextxxx) (well, maybe except nextLine :D). – Pshemo Apr 19 '14 at 21:03

0 Answers0