数组
一.打印左直角三角形
package com.cy.test.forwhile;
public class ForTest01 {
public static void main(String[] args) {
ForTest01.forTest01();
}
public static void forTest01(){
//外层控制纵向层数,共九层.
for (int i = 0;i < 9;i++){
//内层控制横向变化
for (int j = 0;j <= i;j++){
//不换行打印
System.out.print("* ");
}
//内循环结束换行重新循环.
System.out.println();
}
}
}
结果:
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
二.打印九九乘法表
package com.cy.test.forwhile;
public class ForTest02 {
public static void main(String[] args) {
forTest02();
}
public static void forTest02(){
//外循环控制纵向层数,共九层.
for (int i =