Mystery.java


Below is the syntax highlighted version of Mystery.java from §4.3 Linked Structures.


/*************************************************************************
 *  Compilation:  javac Mystery.java
 *  Execution:    java Mystery
 *
 *  An ill-posed class.
 *
 *  % java Mystery
 *  Exception in thread "main" java.lang.StackOverflowError
 *        at Mystery.<init>(Mystery.java:16)
 *        at Mystery.<init>(Mystery.java:18)
 *        at Mystery.<init>(Mystery.java:18)
 *        at Mystery.<init>(Mystery.java:18)
 *
 *************************************************************************/


public class Mystery {
    private Mystery x = new Mystery();


   public static void main(String[] args) {
      Mystery mystery = new Mystery();
   }


}



Last updated: Tue Jan 24 15:59:16 EST 2006.
Copyright © 2004, Robert Sedgewick and Kevin Wayne.