Why the main() method in Java is always static?

0 votes
public static void main(String args[])

Can someone explain why this method is always static? I mean if there is some specific reason, please do explain.

May 8, 2018 in Java by misc.edu04
• 1,380 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

As you might know, static here is an access modifier, which is used for the memory management. It can be used with various variables, methods, blocks and nested classes.

When a method is declared as static:

  1. It belongs to the class and not to the object of the class

  2. It can be then invoked, without the using the object of the class

  3. Also, it can access the static members of a class and edit them.

By using the static keyword with a method, basically helps in removing the ambiguity in case there is some other main method in your program.

answered May 8, 2018 by geek.erkami
• 2,320 points

Related Questions In Java

0 votes
1 answer
0 votes
1 answer

What is the concept of Immutability for strings in Java ? Why are strings immutable ?

According to Effective Java, chapter 4, page 73, ...READ MORE

answered May 11, 2018 in Java by Rishabh
• 3,520 points
0 votes
1 answer

Why there is the need of getters and setters in java

In Java getters and setters are completely ...READ MORE

answered Jun 26, 2018 in Java by scarlett
• 1,280 points
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
0 votes
1 answer

Overriding private or static method in Java

You cannot override a private or static ...READ MORE

answered Jul 30, 2018 in Java by code.reaper12
• 3,450 points
0 votes
2 answers

“Could not find or load main class” mean?

Use the final modifier to enforce good initialization. Avoid returning ...READ MORE

answered Sep 18, 2018 in Java by Sushmita
• 6,840 points
0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,040 points
0 votes
1 answer

How do I replace character from string at specific indexes?

String are immutable in Java. You can't ...READ MORE

answered Apr 26, 2018 in Java by Rishabh
• 3,520 points
0 votes
1 answer

Why clone() method is protected in Java?

The clone() is protected because it is ...READ MORE

answered Nov 12, 2018 in Java by geek.erkami
• 2,320 points
0 votes
1 answer

Listing all the subclasses of a specific class in Java

There is a simple library available for ...READ MORE

answered Jun 7, 2018 in Java by geek.erkami
• 2,320 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.