java学习心得:
之前写的关于输出九九乘法表的代码,如有问题,请联系我。
代码:
/*
* 输出九九乘法表
*/
public class MulTal
{
public static void main(String []args)
{
ShowMulTable table = new ShowMulTable(9);
table.showMulWay();
}
}
class ShowMulTable
{
private int n;
//定义构造函数
public ShowMulTable(int n) {
this.n = n;
}
//循环输出
public void showMulWay()
{
//输出列
for(int i=1;i<=this.n;i++)
{
//输出行
for(int j=1;j<=i;j++)
{
System.out.print(j+ "*" +i +"=" +i*j+" ");
}
//换行
System.out.println();
}
}
}
效果: