Source of ImmutableInteger.java


  1: //: appendixa:ImmutableInteger.java
  2: // From 'Thinking in Java, 2nd ed.' by Bruce Eckel
  3: // www.BruceEckel.com. See copyright notice in CopyRight.txt.
  4: // The Integer class cannot be changed.
  5: import java.util.*;

  7: public class ImmutableInteger {
  8:   public static void main(String[] args) {
  9:     ArrayList v = new ArrayList();
 10:     for(int i = 0; i < 10; i++) 
 11:       v.add(new Integer(i));
 12:     // But how do you change the int
 13:     // inside the Integer?
 14:   }
 15: } ///:~