+ 2

The compiler is throwing an error that there is no public class but I am unable to find any mistake.

import java.util.Scanner; class sample { public static void main(String[] args) { Scanner input=new Scanner(System.in); int x=input.nextInt(); System.out.println("x:"+x); } }

30th May 2018, 1:14 PM
harshit
harshit - avatar
3 Answers
+ 5
harshit It works fine. No error
30th May 2018, 1:28 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 1
The code is okay maybe the problem could be the compiler
31st May 2018, 3:54 AM
Peter Muriithi
Peter Muriithi - avatar
0
in which compiler you have tried?
30th May 2018, 1:54 PM
harshit
harshit - avatar