"Objects that are instances of an inner class exist within an instance of the outer class"
Even though I attempt to create an independent instantiation of the inner class, the outer class is always there because of the statement above.
Is that ture?
If true, then that would also mean the inner class holds a reference to the outer class. With the anonymous outer class, it (outer) would "live" until the inner class goes out of scope.
Yes?
AirJet.java
public class AirJet {
public int model = 777;
class Engine{
public Engine() {
model = 747;
}
public int getModel(){
return model;
}
}
}
AirJetDemo.java
public class AirJetDemo {
public static void main(String[] args) {
// instantiation 1
AirJet.Engine engine = new AirJet().new Engine();
System.out.println("Model: " + engine.getModel());
}
}