Skip to content

Instantly share code, notes, and snippets.

@amay077
Created April 27, 2011 13:49
Show Gist options
  • Select an option

  • Save amay077/944277 to your computer and use it in GitHub Desktop.

Select an option

Save amay077/944277 to your computer and use it in GitHub Desktop.
froyo と Gingerbread の違い
public class Hoge { // implements Comparable してない
private int num = 0;
public Hoge(int num) { this.num = num; }
}
@Override
public void onCreate() {
Set<Hoge> hogeSet = new TreeSet<Hoge>();
hogeSet.add(new Hoge(1)); // ← Gingerbread だとここで例外
hogeSet.add(new Hoge(2)); // ← froyo 以前だとここで例外
}
@amay077
Copy link
Copy Markdown
Author

amay077 commented Apr 27, 2011

Comparable を実装してないクラスを TreeSet または TreeMap に add (or put) すると、

  • froyo では2回目の add で ClassCastException が発生する
  • Gingerbread では1回目の add で ClassCastException が発生する
    という違いがありました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment