I found something like this and I have a question why this works and how JVM parses it?
class app {
public static void main(String[] args) {
}
public void foo() {
System.out.print("Hello World");
}
{
foo();
}
}
Of course, there's not showing message (because foo()
is not in main function), but I'm thinking why code in just {} are not throwing an error.
Here's in online compiler: http://goo.gl/TLv3JH