public class Test {
public static void main(String[] args) { int k=1 ; int j=k+1;
if(k<6){ k=k+1;j=k*j;
}else if(k>=6){ System.out.println(k+","+j);
}
}
保存的文件名必须是Test.java
然后在CMD命令行输入javac Test.java进行编译,
编译成功后,即可输入java Test运行程序
public class test {
public static void main(String[] args) {
int k = 1;
int j = k + 1;
do {
k = k + 1;
j = k * j;
} while(k<6);
System.out.println(k + "," + j);
}
}