提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用for循环打印3x3矩阵
public class Main { public static void main(String[] args) { for(int i = 1; i <= 3; i++) { for(int j = 1; j <= 3; j++) { /** from nowjava.com - 时 代 Java**/ System.out.print(i + "" + j); // Print a tab, except for the last number in a row if (j < 3) { System.out.print("\t"); } } // Print a new line, except after the last line if (i < 3) { System.out.println(); }/** N o w J a v a . c o m 提 供 **/ } } }