The problem was:
The challenge here is to read lines of input until you reach EOF, then number and print all lines of content.
Hint: Java's Scanner.hasNext() method is helpful for this problem.
Input Format
Read some unknown lines of input from stdin(System.in) until you reach EOF; each line of input contains a non-empty String.
Output Format
For each line, print the line number, followed by a single space, and then the line content received as input.
This code returns error:
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1585)
at Solution.main(Solution.java:14)
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
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. */
int x=1;
Scanner scanner= new Scanner(System.in);
do{
String s=scanner.nextLine();
System.out.println(x+" " + s);
x=x+1;
}while(x!=0);
scanner.close();
}
}