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 9, 2018 in Java by misc.edu04
• 1,450 points
2,099 views

1 answer to this question.

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 9, 2018 by geek.erkami
• 2,680 points

Related Questions In Java

0 votes
1 answer

Why main method is static in Java?

In Java, the `main` method is required ...READ MORE

answered Oct 19, 2023 in Java by anonymous
• 3,360 points

edited Oct 19, 2023 by anonymous 703 views
0 votes
2 answers

Why it is not possible to define a static method in a Java interface?

Interfaces are concerned with polymorphism which is ...READ MORE

answered Aug 27, 2019 in Java by Sirajul
• 59,230 points
2,069 views
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,620 points
1,601 views
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,290 points
1,964 views
0 votes
1 answer

Overriding private or static method in Java

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

answered Jul 31, 2018 in Java by code.reaper12
• 3,500 points
16,460 views
0 votes
2 answers

When to use static methods

Java main() method is always static, so that compiler ...READ MORE

answered Dec 29, 2020 in Java by Reshma
998 views
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,920 points
4,516 views
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,140 points
4,103 views
0 votes
1 answer

Why clone() method is protected in Java?

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

answered Nov 13, 2018 in Java by geek.erkami
• 2,680 points
4,594 views
+2 votes
3 answers

Listing all the subclasses of a specific class in Java

Try with BurningWave core library. Here an ...READ MORE

answered Dec 29, 2019 in Java by anonymous
• 460 points

edited Jan 9, 2020 by anonymous 14,501 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP