+ 3

Can someone explain to me what is this code doing?

(I'm not asking why is the code not working, I'm asking what is it doing) https://code.sololearn.com/ciHUxd1FOxv5/?ref=app

12th May 2018, 11:57 AM
Ibaadi Jaya
Ibaadi Jaya - avatar
4 ответов
+ 3
if you comment out the last 2 lines (that are out of the class) it will print "Hello World!" the last 2 lines are out of a class, this is incorrect java syntax and makes the compiler fail. e.g. with the offending lines commented out: public class Program { public static void main(String[] args) { System.out.println("Hello World!"); } } //Program A = new Program; //A.main;
12th May 2018, 12:04 PM
ifl
ifl - avatar
+ 2
That's because I thought we can create objects of a class after defining it... My bad... 😂
12th May 2018, 12:08 PM
Ibaadi Jaya
Ibaadi Jaya - avatar
+ 1
In sololearn playground you can define more than one class that call each other, eg this way: https://code.sololearn.com/cM3lFGUyMfTY/?ref=app
12th May 2018, 12:37 PM
ifl
ifl - avatar
+ 1
The main method is static, so it doesn't an object to run.
15th May 2018, 9:04 PM
CoolGuyPro1001
CoolGuyPro1001 - avatar