Can i get any error if i don't declare String args [] in main method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can i get any error if i don't declare String args [] in main method

Can i get any error if i don't declare String args [] in main method

3rd Dec 2019, 12:48 PM
Kagupati.Sampath Raja Raghupathi
Kagupati.Sampath Raja Raghupathi - avatar
3 Answers
+ 1
you will not get an error in compilation time , but the code will not run. because the Java Virtual Machine looks for a main with (String [] args) in runtime, if it's not found it will stop.
3rd Dec 2019, 12:57 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
You will get an error at only runtime, saying that the main method is not found for the specified class name.
3rd Dec 2019, 1:15 PM
Avinesh
Avinesh - avatar
0
Hello Kagupati.Sampath Raja Raghupathi If you use an IDE like Eclipse you get a message the code don't run without a main method. Please take a look at the sololearn Tutorials. Regards kiuziu
3rd Dec 2019, 6:50 PM
Kiuziu 💘 Berlin
Kiuziu 💘 Berlin - avatar