Mega Code Archive

 
Categories / Java / Class
 

Creating instances of inner classes

// : c08:Parcel11.java // Creating instances of inner classes. // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002 // www.BruceEckel.com. See copyright notice in CopyRight.txt. public class Parcel11 {   class Contents {     private int i = 11;     public int value() {       return i;     }   }   class Destination {     private String label;     Destination(String whereTo) {       label = whereTo;     }     String readLabel() {       return label;     }   }   public static void main(String[] args) {     Parcel11 p = new Parcel11();     // Must use instance of outer class     // to create an instances of the inner class:     Parcel11.Contents c = p.new Contents();     Parcel11.Destination d = p.new Destination("Tanzania");   } } ///:~