0
why have we use public static void instead of public void?
Also can anyone describe the part by part of output line statement system.out.printin("Hello World")
6 Answers
+ 2
The static keyword means that you don't need to create an object of the class to be able to use the method.
And it's println (lowercase L), not printin.
0
Public static void lets you to access method from out of your class or even package without creating object of class it belongs to! So why we have to use is dependent to what type of access we need, for example main method is called by runtime environment, not through any of our own code to run for first time so it requires direct access and we must define it as public static unless your main method is unaccessible and program doesnt runs! Otherwise its your own choice
0
System is the class defined under package java.lang which is imported by default!! out is the static object of class PrintStream defined under class System, so it is being accessed directly using classname, and prinln() is method under PrintStream class which is accessed through static object out in order to print the data you passed as parameter over the console screen!
0
More like the JVM can't access your code so without the static keyword, nasty errors will pop out.
- 1
ohk...
without static it would not execute?
- 1
because its rules