求高手指点~
小弟做了个发牌的,随机2副牌平均发给4个人,在验证是否拿到重复牌的地方编译错误。public static void main(String[] args) {
String[] card = { "黑桃A", "黑桃2", "黑桃3", "黑桃4", "黑桃5", "黑桃6", "黑桃7",
"黑桃8", "黑桃9", "黑桃10", "黑桃j", "黑桃Q", "黑桃K", "红桃A", "红桃2", "红桃3",
"红桃4", "红桃5", "红桃6", "红桃7", "红桃8", "红桃9", "红桃10", "红桃J", "红桃Q",
"红桃K", "方块A", "方块2", "方块3", "方块4", "方块5", "方块6", "方块7", "方块8",
"方块9", "方块10", "方块J", "方块Q", "方块K", "梅花A", "梅花2", "梅花3", "梅花4",
"梅花5", "梅花6", "梅花7", "梅花8", "梅花9", "梅花10", "梅花11", "梅花12",
"梅花13" ,"大王","小王","黑桃A", "黑桃2", "黑桃3", "黑桃4", "黑桃5", "黑桃6", "黑桃7",
"黑桃8", "黑桃9", "黑桃10", "黑桃j", "黑桃Q", "黑桃K", "红桃A", "红桃2", "红桃3",
"红桃4", "红桃5", "红桃6", "红桃7", "红桃8", "红桃9", "红桃10", "红桃J", "红桃Q",
"红桃K", "方块A", "方块2", "方块3", "方块4", "方块5", "方块6", "方块7", "方块8",
"方块9", "方块10", "方块J", "方块Q", "方块K", "梅花A", "梅花2", "梅花3", "梅花4",
"梅花5", "梅花6", "梅花7", "梅花8", "梅花9", "梅花10", "梅花11", "梅花12",
"梅花13" ,"大王","小王"};
Random r= new Random();
String[] name={"八戒","悟空","唐僧","沙僧"};
String[] bajie=new String[card.length/4];
String[] wukong=new String[card.length/4];
String[] tangseng=new String[card.length/4];
String[] shaseng=new String[card.length/4];
boolean[] used=new boolean[card.length];
int o=0,p=0,u=0,y=0;
for(int j=0;true;j++){
int index=r.nextInt(card.length);
if(card[index]=card[used]){continue;}//这里编译错误,求指点
if(j%4==0){bajie[o++]=card[index];}
else if(j%4==1){wukong[p++]=card[index];}
else if(j%4==2){tangseng[u++]=card[index];}
else{shaseng[y++]=card[index];}
}
System.out.println("八戒拿到的牌"+Arrays.toString(bajie));
System.out.println("悟空拿到的牌"+Arrays.toString(wukong));
System.out.println("唐僧拿到的牌"+Arrays.toString(tangseng));
System.out.println("沙僧拿到的牌"+Arrays.toString(shaseng));
}