Why we more often use static void while defining a method? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we more often use static void while defining a method?

27th Jul 2020, 4:56 PM
Samba_Chinta
Samba_Chinta - avatar
2 Answers
+ 3
- static means that a method can called directly on the class without being associated with the object instance. - void means that the method does not return any value. The main method of a Java application must be - public (can be accessed from any external class) - static (since it will be invoked without creating an object) - void (explained earlier) and collect array parameter — args that contain the command line arguments passed to it as strings
27th Jul 2020, 5:12 PM
Ore
Ore - avatar
+ 2
Who said that mostly static void is used? It all depends on returns type of the method and if it belongs to the class or the instance.
27th Jul 2020, 5:07 PM
XXX
XXX - avatar