qq_onewayforwar_0
2017-08-25 21:59
package game;
public class Paizus {
public int ID;
public String name;
public Paizus(int ID, String name) {
this.ID=ID;
this.name=name;
}
}
package game;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Sumgames{
Map<String,Paizus>newmap=new HashMap<String,Paizus>();
public void pukepai() {
Paizus[] pai= {new Paizus(0,"方片2"),new Paizus(1,"梅花2"),new Paizus(2, "黑桃2"),new Paizus(3, "红桃2"),
new Paizus(4,"方片3"),new Paizus(5,"梅花3"),new Paizus(6, "黑桃3"),new Paizus(7, "红桃3")};
for( int i1=0;i1<8;i1++) {
newmap.put("i1",pai[i1]);
}
System.out.println("总长为:"+newmap.size());
System.out.println("开始洗牌,洗牌后为:");
Set<String> keySet = newmap.keySet();
for (String string : keySet) {
Paizus paizu1=newmap.get(string);
System.out.println(paizu1.name);
}
}
public static void main(String[] args) {
Sumgames test=new Sumgames();
test.pukepai();
}
}
为什么不用putall呢
put是修改吧,add才是添加 remove是删除
Java入门第三季
409792 学习 · 4340 问题
相似问题