import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* 类集转换
* @author Administrator
*
*/
public class TestDemo {
public static void main(String[] args) {
List<String> list = new ArrayList<String>() ;
list.add("h") ;
list.add("h") ;
list.add("sss") ;
Set<String> set = new HashSet<String>() ;
set.addAll(list) ; //将list结合的元素放入set集合中
Map<UUID,String> map = new HashMap<UUID,String>() ;
Iterator<String> ite = set.iterator();
while(ite.hasNext()) {
map.put(java.util.UUID.randomUUID(),ite.next()) ; //数据保存到Map集合中
}
Iterator<Map.Entry<UUID,String>> iter = map.entrySet().iterator() ;
while(iter.hasNext()) {
Map.Entry<UUID,String> mape = iter.next();
System.out.println(mape.getKey()+", "+mape.getValue()) ;
}
}
}
|
|