All Questions

504
votes
19answers
252204 views

What should main() return in C and C++?

What is the correct (most efficient) way to define the main() function in C and C++ — int main() or void main() — and why? If int main() then return 1 or return 0? There are numerous duplicate...
3463
votes
20answers
1453541 views

What does if __name__ == "__main__": do?

What does the if __name__ == "__main__": do? # Threading example import time, thread def myfunction(string, sleeptime, lock, *args): while True: lock.acquire() time.sleep(sleepti...
739
votes
37answers
1502684 views

What does "Could not find or load main class" mean?

A common problem that new Java developers experience is that their programs fail to run with the error message: Could not find or load main class ... What does this mean, what causes it, and how sho...
118
votes
5answers
67814 views

What is the proper declaration of main?

What is the proper signature of the main function in C++? What is the correct return type, and what does it mean to return a value from main? What are the allowed parameter types, and what are their m...
217
votes
13answers
660277 views

What is "String args[]"? parameter in main method Java

I'm just beginning to write programs in Java. What does the following Java code mean? public static void main(String[] args) What is String[] args? When would you use these args? Source code an...
417
votes
36answers
412446 views

Why is the Java main method static?

The method signature of a Java main() method is: public static void main(String[] args){ ... } Is there a reason for this method to be static?
522
votes
31answers
741713 views

Can't execute jar- file: "no main manifest attribute"

I have installed an application, when I try to run it (it's an executable jar) nothing happens. When I run it from the commandline with: java -jar "app.jar" I get the following message: no ...
48
votes
7answers
194881 views

Causes of 'java.lang.NoSuchMethodError: main Exception in thread "main"'

New Java programmers often encounter this message when they attempt to run a Java program: java.lang.NoSuchMethodError: main Exception in thread "main" What does this mean, what can cause it, and w...
16
votes
6answers
6476 views

Why is the type of the main function in C and c++ left to the user to define?

Why is main() a user defined function ? When will I use void main() and int main() ?
29
votes
3answers
107013 views

int main() vs void main() in C

In C, I know that int main() returns an int where void main() does not. Other than that, is there a difference between them? is first better than second?

Previous Next