Hi, Please can someone explain me this basic concept.I have read about it before but can't recollect now. Why does line 3 gives compilation error if I don't write static in front of ReSortComparator class? Also can someone why we make a class static(advantages)?
Thanks in advance
[ December 26, 2007: Message edited by: Moieen Khatri ]
posted 8 years ago
If the nested class is non static and you want to use it in the main() which is static, you would need an instance of the enclosing class to instantiate it. Something like this:
Outer.Inner inner = new Outer().new Inner(); // Outer instance is required [ December 26, 2007: Message edited by: Ahmed Yehia ]