
In Java, there are several points to remember about identifiers. Names used for classes, variables, and methods are called identifiers. Public static void main(String args) − Java program processing starts from the main() method which is a mandatory part of every Java program.Īll Java components require names. Then the file should be saved as 'MyFirstJavaProgram.java' It is also not mandatory to have a public class in the file.Įxample: Assume 'MyFirstJavaProgram' is the class name. When saving the file, you should save it using the class name (Remember Java is case sensitive) and append '.java' to the end of the name (if the file name and the class name do not match, your program will not compile).īut please make a note that in case you do not have a public class present in the file then file name can be different than class name. Program File Name − Name of the program file should exactly match the class name. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case. Method Names − All method names should start with a Lower Case letter.

If several words are used to form a name of the class, each inner word's first letter should be in Upper Case.

You will be able to see ' Hello World ' printed on the window.Ībout Java programs, it is very important to keep in mind the following points.Ĭase Sensitivity − Java is case sensitive, which means identifier Hello and hello would have different meaning in Java.Ĭlass Names − For all class names the first letter should be in Upper Case. Now, type ' java MyFirstJavaProgram ' to run your program. If there are no errors in your code, the command prompt will take you to the next line (Assumption : The path variable is set). Type 'javac MyFirstJavaProgram.java' and press enter to compile your code. Open a command prompt window and go to the directory where you saved the class.

Save the file as: MyFirstJavaProgram.java.
BLUEJ SAMPLE PROGRAMS HOW TO
Let's look at how to save the file, compile, and run the program. * This will print 'Hello World' as the output
