Your preferences have been saved!
» Create a Singleton Object - class MySingleton {   // the static singleton object   private static MySingleton theObject;   private MySingleton() {   }   public static MySingleton createMySingleton() {     if (theObject == null)       theObject = new MySingleton();     return theObject;   }... 17 Feb 12 » The protected keyword - class Villain {   private String name;   protected void set(String nm) {     name = nm;   }   public Villain(String name) {     this.name = name;   }   public String toString() {     return "I'm a Villain and my name is " + name;... 17 Feb 12 » Composition with public objects - class Engine {   public void start() {   }   public void rev() {   }   public void stop() {   } } class Wheel {   public void inflate(int psi) {... 17 Feb 12 » Visibility - public class Visibility {   final int i = 42;   void method1() {     // int i = 13;        // would conflict with line below     for (int i=0; i<10; i++)  // does not corrupt object's i       // for (int i=0; i<3; i++) // not allowed, use j         System.out.println("i = " + i);  // prints 0, 1, ...     System.out.println("i = " + i);    // prints 42   } }... 17 Feb 12