May. 21st, 2008
foundation axiom and class HashSet
May. 21st, 2008 05:28 pm
import java.util.Set;
import java.util.HashSet;
public class SetX {
  public static void main(String[] args) {
    Set<Set<?>> ss1 = new HashSet<Set<?>>();
    Set<Set<?>> ss2 = new HashSet<Set<?>>();
    Set<Integer> si = new HashSet<Integer>() {{ add(0); }};
    ss1.add(si);
    ss1.add(ss1);
    ss1.add(ss2);
    ss2.add(si);
    ss2.add(ss1);
    System.out.println(ss1);
  }
}
Exception in thread "main" java.lang.StackOverflowError
(what's funny, if you add ss1 to itself, it's okay, toString() manages it.