Java End-of-file

  • + 0 comments
    import java.io.*;
    import java.util.*;
    import java.util.Scanner;
    
    public class Solution {
    
        public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
            Scanner scan = new Scanner(System.in);
        int line = 1;
        while(true){
        if (scan.hasNextLine()){
            System.out.printf("%d %s\n", line, scan.nextLine());
            line += 1;
        }
        else{
            break;
        }
        }
        }
        
    }