title: Why doesn't TreeSet.contains() work?
body: <pre><code>public class Empty {
  
      public static void main( String[] args ) {
  
          TreeSet&lt;Class&gt; classes = new TreeSet&lt;Class&gt;();
          classes.add( String.class );
  
          String test = new String();
  
          try{ 
              if( classes.contains(test.getClass()) ){
                  System.out.println( "contains" );
              }
          }catch(ClassCastException cce){
  
              System.out.println( "Expected:  "  + classes );
              System.out.println( "But it was: " + test.getClass() );
          }
      }
  }
  </code></pre>
  
  <p>Why does this throw a <code>ClassCastException</code>?</p>