Learn How to Install JAVA

Your First java Program

 

 

Write Your java Code

Request a Callback

Java Download refrences
 Helloworld.java program Create a new file in notepad write the below code
 
						
class HelloWorld 
	{
		public static void main(String[] args) 
		{
			System.out.println("Hello World!");
		}
	}
						
						
						
						
Save the file with name as HelloWorld.java in your working dir Here we define a new class named as HellWorld by using keyword class
class HelloWorld { Here HelloWorld is an identifier of class name.The entire class members means member variable and functions will exist between opening curly braces and closing curly brases }.
By convention, the name of the main class(class which contain main method) should match the name of the file that holds the program.Its also case sensitive.
Within the class there is a main method,which is entry point of your program
Syntax detail of main method is describe here
  • public: public modifier help JVM to execute the method from anywhere.
  • static: Main method can be called without creating any object. Both modifiers public and static can be placed in either order.
  • void: The main method doesn't return any value.
  • main(): Name configured in the JVM.
  • String[]: The main method accepts a single argument which is an array of type String.
System.out.println() prints the text "Hello, World" in the terminal window.Here System is a predefined class that provides access to the system, and out is the variable of type output stream class that is connected to the console.and println() is the method of output stream class to print on console screen. Now nevigate to your working directory in command window(cmd) Compile the java program by command in terminal(cmd) window...

javac HelloWorld.java
It will generate a HelloWorld.class file in your working folder which contains the bytecode version of the program. After successful compilation now run the program by calling JVM ( Java Virtual Machine) to get the output

Execute program by giving command java followed by class name
java HelloWorld
Now you get the desired output "Hello World". Thats it!!

java HelloWorld

Request a Callback

JAVA Training in Jaipur,258-SF , Katewa Nagar, Jaipur,302019
Ph: 072406 21224 ,09829708506 , 08432830240

Java Training in jaipur-DZONE Rated
5 Star Rating: Recommended
4.8/5 based on 4 customer reviews