Structure of Java Program
- The program in Java is written in the form of classes, everything in Java is classes.
- The basic structure is like this -
public class file_name_is_class_name{
public static void main(String args[]){
System.out.println("Hello bits and bytes!");
}
- In the above code sample, our main function is in the class whose name would be same as the filename it is written in.
- And there is one more convention that makes it easy to work with code is to have First letter to be Uppercase of class name.
main
function is the one from where the execution of code starts and all other classes and function defined in the code are called in the main function. It acts as the assembly ground for various parts of program to come together and function properly to achieve the goal of the code written.