J
Jenny
Hi,
I read somewhere that a for loop can have a form for ( ; ; ){...}. I
try to understand the code below.
1. Could you tell me why after j becomes 1, it jump to line a?
2. Could you tell me why after line a, it jump to line int j =0;?
3. How could one use for ( ; ; ){...} in a real app?
public class Ball {
public static void main(String[] args){
int k;
k=1;
for ( ; ; ){
int j =0;
j++;
if (j>1){
System.out.println("j is " + j);
break;} //line a
}
}}
I read somewhere that a for loop can have a form for ( ; ; ){...}. I
try to understand the code below.
1. Could you tell me why after j becomes 1, it jump to line a?
2. Could you tell me why after line a, it jump to line int j =0;?
3. How could one use for ( ; ; ){...} in a real app?
public class Ball {
public static void main(String[] args){
int k;
k=1;
for ( ; ; ){
int j =0;
j++;
if (j>1){
System.out.println("j is " + j);
break;} //line a
}
}}