I came across this code with a very bizzare syntax, but apparently it compiles and runs without an error:
class z{
z(String s){
System.out.println(s);
System.exit(0);
}
static{new z("Hello, World!"}
}
I understand everything that happens in the constructor, but what's going on with
static{new z("Hello, World!"}
...? Is this some kind of a shot-hand syntax for public static void main() ?
class z{
z(String s){
System.out.println(s);
System.exit(0);
}
static{new z("Hello, World!"}
}
I understand everything that happens in the constructor, but what's going on with
static{new z("Hello, World!"}
...? Is this some kind of a shot-hand syntax for public static void main() ?