Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package pkg3tazad;
- import java.util.HashMap;
- import java.util.TreeSet;
- /**
- *
- * @author Asus
- */
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- int niza[];
- niza = new int[]{23,5,17,32,2,8,4,37,3,5,27,12,15,19,20,6,3,9,29,11};
- //smesti niza vo hash
- HashMap <Integer, TreeSet<Integer>> map=new HashMap();
- for(int i=0;i<niza.length;i++){
- int k=niza[i];
- TreeSet<Integer> set=map.get(k);
- if(!map.containsKey(k)){
- set=new TreeSet();
- set.add(k);
- }
- else set.add(k);
- map.put(k, set);
- }
- System.out.println(map.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement