SELENIUM BASICS:


SELENIUM WEBDRIVER:


TESTNG:


REPORTS:


BUILD & CONTINUOUS INTEGRATION TOOLS:


CROSS BROWSER TESTING:


MOBILE TESTING:


AUTOMATION FRAMEWORKS:


API Testing:


INTERVIEW QUESTIONS:


SAMPLE RESUME:

Explain Java Main Method public static void main (String[] args)

In the last post, we have seen how much Java is required to learn Selenium and today in this post we will see detail explanation on Java main() method i.e., public static void main(String[] args)

When you start learning Java, the first method you encounter is public static void main(String [] args). The starting point of any Java Program is the main() method. It is one of the important methods of Java. Technically, the main method is the starting point where the Java program starts its execution. JVM always look for this method signature to start running an application.

Syntax of the main method is as follows

Note: public static void main(string[] args) can also be written as public static void main(String args[]). Don’t get confused.

Each word has its purpose. Let’s break the method signature and see in detail.

public:

public is an access modifier. The scope of public access modifier is everywhere. It has no restrictions. Data members, methods and classes that declared public can be accessed from anywhere. If you make a main() method public then it is allowed to be executed by any program globally. If you make a main() method non-public then it is not allowed to be executed by any program.

static:

JVM can not create an object of class at run time to access the main method. By declaring the main() method as static, JVM can invoke it without instantiating the class. If we don’t declare the main method as static then JVM cannot call it to execute the program.

void:

Void means the Method will not return any value. In Java, every method provides the return type whereas Java main method doesn’t return any value. Java program starts with main method and terminates once the main method is finished executing. If we make main method to return a value, JVM cannot do anything with the returned value. So there is no need to return any value.

main:

main is the name of Java main method. It is the first thing that runs when you compile and run the Java program. The main method is searched by JVM as the starting point where the Java program starts its execution.

String[] args

String[] args is a parameter that accepts inputs. The name of the String array is ‘args‘ but it can be of anything based on users choice. The type of args is always String[] because Java main method accepts only a single argument of the type String array. We can replace the array name with anything then also it works fine. i.e. String[] raj or String[] stm

Related posts:

Explain Java Main Method

Sharing is caring.

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Like This Post?

We have a lot more where that came from?

We only send really good stuff occasionally, promise.

Rajkumar SM

Leave a Comment

Your email address will not be published. Required fields are marked *

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on whatsapp

Recent Posts:

Scroll to Top
API Testing eBook

DOWNLOAD FOR FREE