Table of Contents
Java class and the main method
In this tutorial, we will discuss the concept of Java class and the main method.
In this post, we are going to learn how to create Java class and main method
Explanation of Java class and the main method
In the above code example in Java, We are using java main method, each word have different meanings and purpose of the main method in Java
Declaration of class
A class declared by class keyword in java. The class body is enclosed between curly braces. The data members methods constructor and object are declared Between open and end curly braces in the class
The data member or variable declared two types
- local variables
- Instance variables
class Class_Name
//class keyword and class name
{
data members…..
methods……
}
Declaration of Java main method
public :
it is an Access modifier, which defines who can access this method.public is a reserved word means that this Method will be accessible by any other class or anyone
static :
it is a keyword allows the main() method to be called before any objects of the class have been created
void:
it is a reserved word in java, which is known as a return type and all methods are required to have any one return type. But The void keyword denotes that this method never returns a value
main:
it is the name of the method , This method name is the starting point of the program
String args[]:
it is the parameter to the main method
Suggested for you
Oop concept class object and method in Java