Advertisement
Guest User

treta

a guest
Aug 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package pkg3tazad;
  7.  
  8. import java.util.HashMap;
  9. import java.util.TreeSet;
  10.  
  11. /**
  12. *
  13. * @author Asus
  14. */
  15. public class Main {
  16.  
  17. /**
  18. * @param args the command line arguments
  19. */
  20. public static void main(String[] args) {
  21. // TODO code application logic here
  22. int niza[];
  23. niza = new int[]{23,5,17,32,2,8,4,37,3,5,27,12,15,19,20,6,3,9,29,11};
  24. //smesti niza vo hash
  25. HashMap <Integer, TreeSet<Integer>> map=new HashMap();
  26. for(int i=0;i<niza.length;i++){
  27. int k=niza[i];
  28. TreeSet<Integer> set=map.get(k);
  29. if(!map.containsKey(k)){
  30. set=new TreeSet();
  31. set.add(k);
  32. }
  33. else set.add(k);
  34. map.put(k, set);
  35. }
  36. System.out.println(map.toString());
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement