You may be using some kind of text editors(eg. notepad, gedit etc.) for writing the program and you have to save your program with the extension .java
Whenever you save the program make sure that the program name must be the name of the class in which the main function is written.
eg:
The program should be saved as Demo.java because main function resides in that class.
Whenever you save the program make sure that the program name must be the name of the class in which the main function is written.
eg:
Class Demo
{
public static void main(String arg[])
{
System.out.println("This is a sample java program");
}
}
The program should be saved as Demo.java because main function resides in that class.
No comments :
Post a Comment