Java class and main method explanation

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
variables defined within a class called instance variable and defined within a method or contractor called as a local variable
The methods and variables defined within a class are called as members data members of the class

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

The method in Java language

Method overloading in Java

Method overriding in Java

Constructor overloading in Java

Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

11 months ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

11 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

11 months ago

This website uses cookies.