Save your program file as "HelloWorld.java". I’ve created a directory in My Documents called "Java" to store all the example Java programs in one place. It makes it easy for me to find them when I need them. You might consider creating a similar directory on your computer.
It’s very important that you save the text file as "HelloWorld.java". Java is a little bit picky about filenames. If you look at the code you will see the statement:
It’s an instruction to call the class "HelloWorld". The filename must match this class name, hence the name "HelloWorld.java". The extension of ".java" tells the computer that it’s a Java code file.