+ 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
4 Réponses
+ 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;
+ 2
That's because I thought we can create objects of a class after defining it... My bad... 😂
+ 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
+ 1
The main method is static, so it doesn't an object to run.