Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Glenn Duncan   on Apr 08 In Java Category.

  
Question Answered By: Volney Fischer   on Apr 08

Static inner classes do not hold a reference to their containing object instance while non-static  ones do. I personally prefer to define inner static  classes if no instance referencing is needed; it makes refactoring a hell a lot easier. Look at the following example if something in your head is whispering what the hell:


class SomeA {
private int a;

 class  SomeB {

void xyz() {
int something_different = SomeA.this.a; // Right here! Static classes won't have access to this.
}
}
}

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on nested class Or get search suggestion and latest updates.


Tagged: