在以前的学习过程中,曾经使用嵌套循环的方式实现九九乘法表,昨天在网路上发现有高人使用了另外一种方法,简洁易懂。在此学习。
public static void main(String[] args) { for(int i = 1, j = 1; j <= 9; i++ ){ System.out.print(i + "*" + j + "=" + i * j + "\t"); if(i == j){ System.out.println(); j ++; i = 0; } } }
from:http://topic.youkuaiyun.com/u/20090404/00/7189d7f7-302a-4c26-a276-0c72f3f80442.html