在类中定义一个非静态方法,该方法中用while循环输出乘法口诀表。
public class NineNineTable {
public static void main(String[] args) {
new NineNineTable();
}
public NineNineTable() {
int i = 1,j = 1;
while(i <= 9) {
j = 1;
while (j <= i) {
System.out.print(i + "×" + j + "=" + i*j + " " );
j++;
}
System.out.println( );
i++;
}
}
}