Java End-of-file

  • + 0 comments

    public class Solution {

    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int a = 0;
        String s;
        while(sc.hasNext()){
            s = sc.nextLine();
            a++;
            System.out.println(a+" "+s);
            if(s.endsWith("Read me until end-of-file."))
                break;
        }
    
         /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
    }
    

    }