I really want to know about how two forloop works to iteratiating the values
looping explanination
Collapse
X
-
@OP: suppose you are a loop and you print the value of variable 'jos' three
times plus the loop counter value; here you are:
[code=java]
int jos= 42;
for (int windx= 0; windx < 3; windx++) { // <-- you
System.out.prin tln(jos+" "+windx);
}
[/code]
Now suppose I'm also a loop and I activate you four times: Here I am:
[code=java]
for (int jos= 0; jos < 4; jos++) { // <-- me
for (int windx= 0; windx < 3; windx++) { // <-- you
System.out.prin tln(jos+" "+windx);
}
}
[/code]
Now try to guess/figure out what gets printed.
kind regards,
JosComment
-
could you explain this loop please?
Given a list of integers and an integer variable declared like this:
List<Integer> list;
int max;
and assuming that some values have been added to the list, write a loop which finds the largest value in list and stores it in max.Comment
-
Have a look at the Integer.MIN_VAL UE and the Math.max() method.Originally posted by joej231could you explain this loop please?
Given a list of integers and an integer variable declared like this:
List<Integer> list;
int max;
and assuming that some values have been added to the list, write a loop which finds the largest value in list and stores it in max.
kind regards,
JosComment
Comment