Variable Shadowing

Another problem in the following code, at the section I have commented as //***** the compiler throws the following error ..."'this' cannot be referenced from a static context". Could anyone explain what I am doing wrong? Please.

Peros, I tried compiling ur code. I get an error saying "No enclosing instance of class Test in scope ......." at the same commented line. If u know inner classes, the first two soultions wud work. ReTest is in the current position an inner class to TEst Class. 1. U cud change the error giving statement to

Test.ReTest SecondTest = new Test().new ReTest(); //******

Now the inner class ReTest is properly instantiated. 2. Or u cud introduce a "static" keyword as a modifier to ReTest class definition. 3> Or u cud just move out the whole ReTest class portion beyond and after the main() method. This wud also work fine. Now they are just two distict classes .

Thanks for the response. I am actually studying from the Mughal PGJC book - so I haven't go to inner classes yet (its the next chapter). Regarding your #2 - "static modifier". I wasn't aware that a class can be static?? Isn't a class an object? I thought only variables and methods could be "static" ??

Personally I think that you just typoed on the code. You left the final bracket out of the first class, causing the second class to be an inner class of the first. Fix that and THEN see what your problems are. (If you have not studied inner classes, then you do not need to get confused about static inner classes - which are actually called top-level nested classes - a little nitpik in the Java Language Specification.)

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com