package three;
import java.util.*;
public class test {
public static void main(String[] args) {
List<String> data=new ArrayList<>();
String[]scences={"A","B","C","D"};
Random sc=new Random();
for (int i = 0; i < 80; i++) {
int index= sc.nextInt(4);
data.add(scences[index]);
}
Map<String,Integer> tongji=new HashMap<>();
for (String s : data) {
if(tongji.containsKey(s)){
tongji.put(s,tongji.get(s)+1);
}else{
tongji.put(s,1);
}
}
System.out.println(tongji);
}
}
package three;
import java.util.*;
public class test {
public static void main(String[] args) {
List<String> data=new ArrayList<>();
String[]scences={"A","B","C","D"};
Random sc=new Random();
for (int i = 0; i < 80; i++) {
int index= sc.nextInt(4);
data.add(scences[index]);
}
Map<String,Integer> tongji=new HashMap<>();
for (String s : data) {
if(tongji.containsKey(s)){
tongji.put(s,tongji.get(s)+1);
}else{
tongji.put(s,1);
}
}
System.out.println(tongji);
}
}