This topic has been archived. It cannot be replied.
-
工作学习 / IT杂谈 / help me,jabber!Thank you very much!dog()
{
for (int i=1;i<10;)
System.out.println(i);
}
this function will never end ,it will print endless1 because it do nothing after the judgement i<10
but why the function below runs ok?
public static void print(Collection c)
{
for (Iterator x=c.iterator();x.hasNext();)
System.out.print(x.next()+" ");
System.out.println();
}
-forever(kp);
2001-3-15
{365}
(#33373@0)
-
The structure of a for-loopfor(...; ...; ???) {
//code -------------
}
After the "code" is executed, ??? will be executed. So, if you like,
you can change the above code into the following form
for(...; ...; ) {
//code -------------
???
}
I hope I have examplified the execution sequence here.
I strongly suggest you grab a Java or C++ textbook and look into the
explanation of for-loop. You will be OK.
-jabber(jabber);
2001-3-15
{407}
(#33374@0)