I am a beginner in Java. Could anyone please help me understand the following concept?
What I have done here is I tried to create a class as Sample
, which I mentioned below, where I am printing You are in Main Method
class Sample
{
public static void main(String args[]) {
System.out.println("You are in Main Method");
}
}
and saved this java file as Student.java.
I didn't get any error in Eclipse.
Now, I had specified a public
in front of this class as public class Sample
and I am getting an error.
Could anyone please clarify for me with the right answer, as I am finding this to be difficult to understand?