if you want to refer to a class variable via the class name, eg Test4.something then by definition something is a class variable. But since flag is an instance variable (non-static) you can still refer to it via the class name, except that you need to flag it with this, as in the example, Test.this.flag Hope this helps
if (Test4.this.flag); The variable flag of the outer class is referred inside the inner class by Test4.this.flag. Since there is a semicolon at the end of the 'if' statement,the if condition ends there. The next statement is the call to the sample() method.So,it displays Sample.If you remove that semicolon and run the program,the boolean condition of 'if' is false and so there is no output.
You can have block statements in a method/inner class/top-level class ...etc : BTW - { ... } is a block statement. void foo() { { System.out.println("I'm in a block haha"); } } There is nothing wrong with it. Brian
I will open the floodgates of his own worst nightmare! All in a tiny ad: