|
本帖最後由 MemoriseOff 於 2012-2-12 11:48 編輯
class test
{
int i01,i02,sum01=0,sum02=1;
test(int i01)
{
for(int i02=1;i02<=i01;i02++)
{
sum01+=i02;
sum02*=i02;
}
System.out.println("1+2+3+....+"+i01+"="+sum01);
System.out.println("1*2*3*....*"+i01+"="+sum02);
}
}
import javax.swing.*;
public class test01
{
public static void main(String args[])
{
int num;
String str01;
do
{
str01=JOptionPane.showInputDialog("請輸入大於一以上數字");
num=Integer.parseInt(str01);
}while(num<1);
test t=new test(num);
}
}
編譯會出錯訊息
test01.java:15: error: class, interface, or enum expected
import javax.swing.*;
^
1 error |
|