Linked Questions

17 votes
9 answers
11k views

If we declare the class with default scope(non-public) and public main method it executes successfully. Here class scope is mote stricter than main method scope. But if we declare main method as ...
Ninja's user avatar
  • 2,098
13 votes
9 answers
6k views

I have heard some people saying " if main is not static then JVM could create an object of class containing main and call that main through object. But the problem is how JVM knows which constructor ...
Happy Mittal's user avatar
  • 3,767
6 votes
1 answer
37k views

Why is the main declared as public and static? public static void main(String arg[]) {} acording to ans in java "The method is static because otherwise there would be ambiguity: which constructor ...
AK4's user avatar
  • 71
-1 votes
5 answers
1k views

Possible Duplicate: Why is the Java main method static? JAVA supports reflection still JAVA needs main method to be static why? Using reflection we can create the object of class and even call ...
Amol Fasale's user avatar
2 votes
7 answers
2k views

Why should we declare a main method? I know that the main method is the starting point of the class. But why should only we declare it as public static void main(String args[])? Why can't we declare ...
user2699954's user avatar
0 votes
2 answers
4k views

When we tried to run the following program then it successfully runs. class with { public static void main(String args[]) { System.out.println("With static"); } } but even if we ...
Manohar Kumar's user avatar
-3 votes
3 answers
3k views

Possible Duplicate: Why is the Java main method static? What's the reason of main method to be static? Why isn't just public void main(String[] args)? I think I understand what static means, but I ...
good_evening's user avatar
  • 21.9k
0 votes
1 answer
1k views

The following code gives error because i am not put static keyword to main method. Please explain why main method not working without static keyword. public class Test { public void main(String args[]...
user avatar
-1 votes
1 answer
1k views

I'm new to programming in Java (even though I'm used to code in C, html and some other languages (vaguely)). I'm trying to create a simple Hello World program, and I'm unsure of why, and what the "...
mazunki's user avatar
  • 732
-1 votes
1 answer
111 views

public class Question { public void doThing() {} public static void main(String[] args) { doThing(); } } Should the doThing() method be declared static to be used in ...
Kevin Ocampo's user avatar
-8 votes
1 answer
120 views

Onetime I forgot to put the static keyword for the main method in my java class. And the program did not work . So the question is why we always need to mark the main method as static?
Geyth Saleh's user avatar
0 votes
0 answers
42 views

class Student{ public **static** void main (String[]arg){ } } Here why we are using static keyword to start a main method. From my knowledge I can say Static will get memory and it can ...
Jaga Dish's user avatar
163 votes
22 answers
500k views

Normally, I use this in constructors only. I understand that it is used to identify the parameter variable (by using this.something), if it have a same name with a global variable. However, I don'...
guilgamos's user avatar
  • 1,735
68 votes
11 answers
233k views

New Java programmers often encounter messages like the following when they attempt to run a Java program. (Different Java tools, IDEs and so on give a variety of diagnostics for this problem.) Error:...

15 30 50 per page