Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hashtable<Object, Integer> hash= new Hashtable<Object, Integer>();
- Map<Object, Integer> hash= new Hashtable<Object, Integer>();
- SortedSetMultimap<Integer, Object> reverse = TreeMultimap.create();
- public static void main(String[] args) {
- HashMap<String,Integer> map = new HashMap<String,Integer>();
- map.put("A", 1);
- map.put("B", 2);
- map.put("C", 3);
- System.out.println(
- Collections.min(map.entrySet(), new Comparator<Map.Entry<String,Integer>>() {
- @Override
- public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
- return o1.getValue().intValue() - o2.getValue().intValue();
- }})
- .getKey()
- );
- }
- Object minObj= null;
- int min= Integer.MAX_VALUE;
- for(Map.Entry<Object, Integer> x: hash.entrySet()){
- if(x.getValue() < min){
- min= x.getValue();
- minObj= x.getKey();
- }
- }
- Hashtable h = new Hashtable();
- h.put(10, "aaa");
- h.put(1, "aab");
- h.put(12, "aabwqkjdg");
- Set set = h.keySet();
- TreeSet treeSet= new TreeSet();
- treeSet.addAll(set);
- System.out.println("Last :"+treeSet.first());
Add Comment
Please, Sign In to add comment