/*多行注释的快捷键:Ctrl+shift+/
快速格式化代码快捷键:Ctrl+shift+f
自动导入一个包:Ctrl+shift+o
*/
package test_1;
public class Day_2 {
public static void main(String args[]) {
//一个九九乘法表的实现
int c = 0;
for (int a = 1; a <= 9; a++) {
for (int b = 1; b <= a; b++) {
c = a * b;
System.out.printf("%d*%d=%d ",b,a,c);
}
System.out.println();
}
System.out.println("-------------------我是华丽的分割线--------------------------");
// 遍历数组的方法
// 方法1:
int arr[] = new int[3];
for (int a = 0; a < arr.length; a++) {
System.out.println(arr[a]);
}
System.out.println("-------------------我是华丽的分割线--------------------------");
//方法2:
for (int a : arr) {
System.out.println(a);
}
System.out.println("-------------------我是华丽的分割线--------------------------");
//二维数组的遍历
int arr2[][]=new int[][]{
{1,2,3},
{4,5,6},
{7,8,9}
};
for(int i=0;i<arr2.length;i++){
for(int j=0;j<arr2[0].length;j++){
System.out.print(arr2[i][j]+" ");
}
System.out.println();
}
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54