Your First Java program
Lesson#1
Like most other programming language tutorials I will start with writing a Java program that prints “Hello World” on the screen. Here it is:
class P001_HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello World!");
}
}
Program Output on screen:
Hello World!
Why I chose the naming convention P001_HelloWorld.java for my programs?
The answer is that since I will be writing around 200 java programs I want to store then in the directory in the order in which I write them 001… means program #001, I placed a ‘P’ before it because a Java class can not start with a number. Name after the underscore ‘HelloWord’ represents the purpose of the code.
P001_HelloWorld.java means java code example 001 that demonstrates the ‘Hello World’ program. I will use the same convention in rest of my examples.