9.2
int[] numbers={10,20,30,40,50}; for (int i = 0; i < 5; i++) { System.out.println(numbers[i]); } //遍历数组的元素 for (int x:numbers){ System.out.println(x); }
package struct; public class TestDemo { //打印三角形 5行 public static void main(String[] args) { for (int i = 1; i <=5; i++) { for (int j = 5;j>=i;j--) { System.out.print(" "); } for (int j = 1;j<=i;j++) { System.out.print("*"); } for (int j = 1; j < i; j++) { System.out.print("*"); } System.out.println(); } } }