Java End-of-file

  • + 4 comments

    In fact, you can shorten it even further (at a potential loss of readability) by including the print statement within the for loop:

    for(int i = 1; scan.hasNext(); System.out.println(i + " " + scan.nextLine()), i++);