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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 海乃百川 中级黑马   /  2016-8-10 09:03  /  994 人查看  /  12 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

做题遇到的为什么答案给出的是i=3,j=1.有木有大神帮忙解答一下。

12 个回复

倒序浏览
695212308 发表于 2016-8-10 13:05
这太模糊了,看不清啊,能不能复制下代码看下

麻烦帮忙看下
[AppleScript] 纯文本查看 复制代码
public class MyClass {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		int i;
		int j;
		outer:for(i=1;i<3;i++)
			inner:for(j=1;j<3;j++)
			{
			if(j==2)
				
				continue outer;
			System.out.println("Value of i is" +i+"    Value of j is"+j);
			}

	}

}
回复 使用道具 举报

帮忙看下谢谢了
[AppleScript] 纯文本查看 复制代码
public class MyClass {
                                  public static void main(String[] args) {
		// TODO 自动生成的方法存根
		int i;
		int j;
		outer:for(i=1;i<3;i++)
			inner:for(j=1;j<3;j++)
			{
			if(j==2)
			continue outer;
			System.out.println("Value of i is" +i+"    Value of j is"+j);
			}
}
}
回复 使用道具 举报
敲敲乐z 发表于 2016-8-10 20:06
你这代码好难看懂啊,小弟不才看不懂!

网上找的题,我也不是很懂
回复 使用道具 举报
paksung 发表于 2016-8-10 20:50
Value of i is1    Value of j is1
Value of i is2    Value of j is1
结果没问题啊

恩,我现在有点懂了,估计是网上给错答案了吧,写了好几遍
回复 使用道具 举报
695212308 发表于 2016-8-10 21:34
第一次循环i=1进去后j=1,然后不满足if要求,就直接输出一句Value of i is 1    Value of j is1
当j++后 ...

写得好详细,现在终于看懂了,谢谢你了!!!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马