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.
Quickly Find What You Are Looking For
Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.