java语句(for嵌套练习)-java教程读书笔记
时间:2014-04-23 22:17 来源: 我爱IT技术网 作者:山风
语句(for嵌套练习)
class Test
{
public static void main(String[] args)
{
for(int x=0;x<5;x++)
{
for(int y=0;y<=x;y++)
{
System.out.print("*");
}
System.out.println();
}
System.out.println("- - - - - -");
for(int x=1;x<=5;x++)
{
for(int y=1;y<=x;y++)
{
System.out.print(y);
}
System.out.println();
}
}
}
返回结果:
*
**
***
****
*****
- - - - - -
1
12
123
1234
12345
本文来源 我爱IT技术网 http://www.52ij.com/jishu/5557.html 转载请保留链接。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
