Algorithm
Print Hello World
String. Just use print function of java.
Code Examples
#1 Simple Hello World Print in Java Language
Code -
Java Programming
class Hello {
public static void main(String[] args) {
System.out.println("Hello World !");
}
}
Copy The Code &
Try With Live Editor
Output
Demonstration
Let's discuss about the code first, how this Hello World
works.
In this line,
class Hello {
We created a class named Hello
, It's just a user defined class which name is Hello. We can name it anything rather than Hello
. We can name it like HelloWorld
also, if we want.
Next,
public static void main(String[] args) {
In this line, we've defined the main
method. All java programm should contain this main
method. Without this, java programm will not enter into. and here is fixed. We can't use any other name rather than main.
And, we assume you know - How Java compiler Works. When java compiler find this method, it starts to execute the code.
And String[] args
, we passed empty array of string as argument in this method. Let's learn more about argument, parameter later in another chapter.
Next & Final - The main function of the method to print the Hello World.
System.out.println("Hello World !");
This line print Hello World !
string to the compiler.