Basic Program in Java


Let's create the Hello World java Program.

class basic {..}
In Java, every program begins with a class definition. In the program, basic is the name of the class, and the class definition is:

  class basic 
  {
  	......
  	......
  }

For now, just remember that every Java program has a class definition, and the name of the class should match the file name in Java.

public static void main(String[] args) { ... }
This is the main method. Every program in Java must contain the main method. The Java compiler starts executing the code from the main method.For now, just remember that the main function is the entry point of your Java application, and it's mandatory in a Java program.The signature of the main method in Java is

  public static void main(String[] args) 
  {
  	... 
  	.. 
  	...
  }

This is a basic Java program that prints "Welcome Back" to the console. The public class basic declares a public class named basic. The public static void main(String args[]) is the main method which is the entry point for the program. The System.out.println("Welcome Back"); prints the string "Welcome Back" to the console. Overall, this program will print "Welcome Back" to the console when executed.

Source Code

//01 Hello World
public class basic {
    public static void main(String args[])
    {
        System.out.println("Welcome Back");
    }
}

Output

Welcome Back
To download raw file Click Here

Basic Programs