Input Format

Read some unknown  lines of input from stdin( 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.

hackerrank java end of file solution

Java End of File problem solution | HackerRank

import java.util.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(;
        int line_num = 0;
        	System.out.println(++line_num + " " + sc.nextLine());