Public static void | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Public static void

Can someone please explain why public static void always is there?

2nd Dec 2019, 9:11 AM
Walt Rothschild
Walt Rothschild - avatar
6 Answers
+ 1
Walt Rothschild This the main method. You need it to execute your code. But as HonFu mentioned it is better to take it as a fact. You will learn about it if you get introduced into classes/methods.
2nd Dec 2019, 9:28 AM
Denise Roßberg
Denise Roßberg - avatar
+ 1
public static void main(String[] args) public --> access modifier static --> non-access modifier void --> return type This line is a must to run your java code. If you didn't understand any of these kindly complete the java course and you will come to know.
2nd Dec 2019, 10:04 AM
Avinesh
Avinesh - avatar
0
The explanation of this, if the context is still missing (because you're just starting), tends to only lead to more confusion. In my opinion, it's best to just take it as a given and go on with your study of the basics. This will naturally become clear after you studied the tutorial. If not, then at least you'll have the context to understand the explanation.
2nd Dec 2019, 9:14 AM
HonFu
HonFu - avatar
0
does either one of the characters have to be in the code?
2nd Dec 2019, 9:16 AM
Walt Rothschild
Walt Rothschild - avatar
0
Yes, it's necessary in this case.
2nd Dec 2019, 9:16 AM
HonFu
HonFu - avatar
0
Could you give an example?
2nd Dec 2019, 9:18 AM
Walt Rothschild
Walt Rothschild - avatar