Skip to content

Instantly share code, notes, and snippets.

@koher
Created September 29, 2015 22:50
Show Gist options
  • Save koher/e3669bc5a2c391b43f6c to your computer and use it in GitHub Desktop.
Save koher/e3669bc5a2c391b43f6c to your computer and use it in GitHub Desktop.
TreeMap#get gets ClassCastException
import java.util.*;
Map<String, Integer> map = new TreeMap();
map.put("abc", 123);
map.put("def", 456);
map.put("ghi", 789);
map.get("abc");
map.get(123); // java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment