The above code compiles without any problem. According to me it should not compile since in the 2nd line of main method since a private variable is directly accessed using object reference. And also the declaration of i is also making forward referencing to the j variable, which should also give an compilation error. Can any one give me proper explanation.......
Thanks and Regards, Kalai Selvan T. [ November 03, 2004: Message edited by: Kalai Selvan ]
posted 11 years ago
All your code is in one class, so access modifiers do not make any difference. A class can always see all of its own members: fields and methods.
Many types of "forward reference" are perfectly OK in Java. See the Language Specification for more details, if you care about them.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.