模拟随机发牌

public  void testinit(){ 
        List srclist =new ArrayList(8); 
        srclist.add("1"); 
        srclist.add("2"); 
        srclist.add("3"); 
        srclist.add("4"); 
        srclist.add("5"); 
        srclist.add("6"); 
        srclist.add("7"); 
        srclist.add("8"); 
        
        List targetList = new ArrayList(8); 
        
        int length = srclist.size(); 
        Random random = new Random();  
        for (int i = 0,  count = length; i < length; i++,count--) 
        { 
            int index =random.nextInt(count); 
            targetList.add(srclist.get(index)); 
            srclist.remove(index); 
        } 
      System.out.println(targetList); 
    }

你可能感兴趣的:(模拟)