Reputation: 9
class
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
while compiling it was showing error
---------- Compile ----------
Untitled1.java:1: error: <identifier> expected
public class
^
1 error
Output completed (0 sec consumed) - Normal Termination
Upvotes: -4
Views: 6232
Reputation: 311393
You're missing the name of the class:
public class MyFirstClass
// Here -----^
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Note that a public class' name must match the name of the file that declares it.
Upvotes: 0