Java Program Structure


Before going into the Java program language, you need to learn Java program structure.


Simple Java Program

public class Simplejava
{
	public static void main(String []args) 
    {
		System.out.println("Hello World"); // prints Hello World
	}
} 

  • All Java applications start execution by calling the main() method.
  • The public keyword is an access specifier, which allows the programmer to control the visibility of the class member.
  • The static keyword allows the main() method to be called without creating an object. The main method is always executed by the JVM, so it doesn't need to create an object to call the main() method.
  • The void keyword tells the compiler that main() doesn't return a value.
  • The string args[] declares a parameter named args, which is an array of instances of the class string. The args receives any command-line arguments when the program is executed.
  • The system.out.println() is used to display statement.
  • The system is a predefined class that helps to access the system.
  • The output stream is connected to console.

Additional Information

  • Case Sensitive - Java is case sensitive.
  • Class Names - All class names the first letter must be in Upper Case.
  • Program File Name - Java class name and java source(program) file name should be the same.



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.