0

In java why do we use Public and static in the main function/block ?

23rd Jul 2017, 7:40 PM
Shrikant Narvekar
Shrikant Narvekar - avatar
2 Antworten
+ 3
Before the main function, there are no objects created. main () is static because there shouldn't be an object created.
23rd Jul 2017, 7:42 PM
Jonas Schröter
Jonas Schröter - avatar
+ 1
Static means that the method belongs to the class not an object. This is important because as @Jonas says there are not any objects yet. This means that if the method was not static you could not call it. Public also makes the method assessable out side the class allowing windows to call it when it starts the process.
23rd Jul 2017, 9:30 PM
josh mizzi
josh mizzi - avatar