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: Kristin Johnston   on Apr 08

if you declare a nested  class as a static  one, you no longer need to instantiate the wrapped class  since it is static you can simply create a new instance of that, unlike static, if you declare a non-static, you have to create new instance of the parent class and then create your required nested class.
to clear see the following example:

class A {
static calss B {

}
}

B b = new A.B();

---
in case of non-static:

class A {
calss B {

}
}

B b = new A().new B();
OR
A a = new A();
B b = a.new B();


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: