错误纠正
import javax.swing.*;
public class test3{
public static void main (String args[]){
int frequency1=0, frequency2=0, frequency3=0,frequency4=0, frequency5=0, frequency6=0,face;
for (int roll=0;roll<=6000;roll++){
face = 1 + (int)(Math.random()*6);
switch (face) {
case1:frequency1++;
break;
case2:frequency2++;
break;
case3:frequency3++;
break;
case4:frequency4++;
break;
case5:frequency5++;
break;
case6:frequency6++;
break;
}
}
JTextArea outputArea=new JTextArea();
outputArea.setText("Face\tFrequency"+"\n1\t"+frequency1+"\n2\t"+frequency2+"\n3\t"+frequency3+"\n4\t"+frequency4+"\n5\t"+
frequency5+"\n6\t"+frequency6);
JOptionPane.showMessage.Dialog(null,outputArea,"频率",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
[解决办法]
//是showMessageDialog 不是 showMessage.Dialog
这句是正解
[解决办法]
注意你的那个case1 case2 之间没有空格,在case与数字间加上空格,试过了,没问题