break and continue

来源:百度知道 编辑:UC知道 时间:2024/05/09 12:19:19
我有2层循环

一层大的主控循环,里面有2个小循环。

我的计划步骤是:第1个小循环结束后进行第2个小循环 ,第2个结束后,打印出外层循环的INDEX,小循环1的值,小循环2的值,大循环再动下这样循环。

当第1或第2小循环中出现null 就终止。
所以打印出来的应该是

1,A,B
2,,B
3,A,
4,,
这4种情况

我在这2个小循环里放的是break;
现在打印出来的是index值不对了 怎么改、?

我怀疑出在break上
while(true)
{
for(int i=0;i<size;i++)
{
if(i==3)
{break;}
else
{
``~~~~~~~
}
}

for(int i=0;i<size;i++)
{
if(i==3)
{break;}
else
{
``~~~~~~~
}
}

}

楼主的描述真是天马行空。。
我只说当初我学习break和continue的最关键,就是跳出或继续当前循环的当前,指的是break或continue在的最内的一层循环,比如
for(a;b;c;)
for(d;e;f;)
if()break;
printf();
这里的break是跳出for def的循环,但是由于没有跳出大循环,会回到上一个循环检验b是否为真命题,而不是直接执行printf

能贴出代码么?

break是跳出整个循环,continue是中止此次循环,继续下一循环。我不是很明白你什么意思,也没源码。

我自己写了个只是用来说明问题:
public static void main(String args[]){

int inter1,inter2;

List list1 = new ArrayList();
List list2 = new ArrayList();
list1.add('a');
list1.add('b');
list1.add(null);
list1.add('c');
list2.add('A');
list2.add(null);
list2.add('B');
list2.add('C');
inter1 = list1.size();
inter2 = list2.size();

for(int i=1;i<5;i++){
System.out.print(i);
for(int j=0;j<inter1;j++){
if(list1.get(j)==null)
break;
// continue;
else
System.out

sticks and stones may break our bones,but words will break ourhearst是什么意思啊! 求keane的bend and break的mp3下载 翻译:Sticks and stones may break my bones , but words can never hurt me We will provide a break down on non-compliant RoHS components and reasons for departure 翻译:It is a dangerous means of transport and the buses sometimes break down. The sign reads “In case of _________ fire, break the glass and push ________ red button.” 英语Sticks and stones may break my bones,but words can never hurt me.这句话是什么意思? Love can save you,and love can break you!I'm searching for my "Ture Love"~~~ 请问He didn't break the window and refuse to say sorry.这句话应该怎么翻译? me and my heart took a vow from the start .and a vow to my heart I never break.有谁知道以这个为头的