Simple Hello World Program

  • April 27, 2022
  • Java
method overloading and method overriding
Requirement for Java Hello World Program:
Hello World Example:
class Hello{  
    public static void main(String args[]){  
     System.out.println("Hello World! Coderzpy");  
    }  
}  

Save the above file as Hello.java.

In the terminal:

To compile:javac Hello.java
To execute:java Hello
Output:
Hello World! Coderzpy
Parameters used:

Let’s look at what class, public, static, void, main, String[], and System.out.println mean ().

  • In Java, the class keyword is used to declare a class.
  • The visibility is represented by the public keyword, which is an access modifier. It means that it is visible to everyone.
  • static is a keyword. Any method that is declared as static is referred to as a static method. The main advantage of the static method is that it does not require the creation of an object to use. Because the main() method is executed by the JVM, there is no need to create an object to call it. As a result, it conserves memory.
  • The method’s return type is void. It indicates that it does not return any information.
  • The program’s starting point is represented by main.
  • The command line argument is String[] args or String args[]. We’ll go over it in the next section.
  • To print a statement, use System.out.println(). System is a class, out is a PrintStream class object, and println() is a PrintStream class method. In the following section, we’ll look at how the System.out.println() statement works internally.
Compilation Flow:

The Java compiler converts source code into byte code when we compile a Java program with the javac tool.

hello world

Note: We can also use other editors like the eclipse(https://www.eclipse.org/downloads/), also read about the JDK vs JRE vs JVM

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Leave a Reply

Your email address will not be published. Required fields are marked *