A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 19期1910 中级黑马   /  2015-4-23 22:59  /  972 人查看  /  7 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

比如
public static void main(String[] args) {
                sum2();
                }
public staic void sum2() {
                for(int b =0;b<5;b++) {
                        for(int c =0;c<10;c++) {
                                System.out.print("*");
                        }
                        System.out.println();
                }
        }

7 个回复

正序浏览
Ak47_1 中级黑马 2015-4-26 08:30:33
8#
外面的控制循环运行一次 ,内部的循环运行一遍。
回复 使用道具 举报
for嵌套主要是应用于矩形和三角的构造问题上~~外循环表示图形的行数,内循环表示图形的列数~~
回复 使用道具 举报
终于找到了
回复 使用道具 举报

class Example {
        public static void main(String[] args) {
                sanjiao(5,6);
        }
        public static void sanjiao(int a,int b) {
                for(int c =0;c<a;c++) {
                        for(int d =0;d<b;d++) {
                                System.out.print("*");
                        }
                        System.out.println("\n");
                }
                System.out.println("\n");
       
        }
}
回复 使用道具 举报
你想实现什么效果啊?http://bbs.itheima.com/thread-188847-1-1.html,你可以参考一下
回复 使用道具 举报
  for(int b =0;b<5;b++) 可以理解为外循环,用来控制行数的 ,     for(int c =0;c<10;c++) 可以理解为内循环,用来控制列数
回复 使用道具 举报
念法是:for循环 嵌套~   
你这样写已经调用了sum2()方法中的for循环了~  

能否告诉我,你想实现什么效果??
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马