Guest User

Untitled

a guest
Jan 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Hashtable<Object, Integer> hash= new Hashtable<Object, Integer>();
  2.  
  3. Map<Object, Integer> hash= new Hashtable<Object, Integer>();
  4. SortedSetMultimap<Integer, Object> reverse = TreeMultimap.create();
  5.  
  6. public static void main(String[] args) {
  7.  
  8.  
  9. HashMap<String,Integer> map = new HashMap<String,Integer>();
  10.  
  11. map.put("A", 1);
  12. map.put("B", 2);
  13. map.put("C", 3);
  14.  
  15. System.out.println(
  16.  
  17. Collections.min(map.entrySet(), new Comparator<Map.Entry<String,Integer>>() {
  18.  
  19. @Override
  20. public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
  21.  
  22. return o1.getValue().intValue() - o2.getValue().intValue();
  23.  
  24. }})
  25.  
  26. .getKey()
  27.  
  28.  
  29. );
  30. }
  31.  
  32. Object minObj= null;
  33. int min= Integer.MAX_VALUE;
  34. for(Map.Entry<Object, Integer> x: hash.entrySet()){
  35. if(x.getValue() < min){
  36. min= x.getValue();
  37. minObj= x.getKey();
  38. }
  39. }
  40.  
  41. Hashtable h = new Hashtable();
  42. h.put(10, "aaa");
  43. h.put(1, "aab");
  44. h.put(12, "aabwqkjdg");
  45.  
  46. Set set = h.keySet();
  47.  
  48. TreeSet treeSet= new TreeSet();
  49. treeSet.addAll(set);
  50.  
  51. System.out.println("Last :"+treeSet.first());
Add Comment
Please, Sign In to add comment