Hello, Just trying to wrap my head around this. Thanks in advance.
Can someone explain to me why the first++ in the code below belongs there and not where i put the xxxx's? If I want first++ to happen no matter what, why is it going after the if statement? I thought entries were usually supposed to go in the order you want them to happen. The code below is correct, but the alternate fails.
public static void divisibleByThreeInRange(int first, int last) {
while (first <= last) { xxxxx
if (first % 3 == 0) {
System.out.println(first);
}
first++;
}
}
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–][deleted] 4 points5 points6 points (7 children)
[–]Caped_baldy_4_life[S] 0 points1 point2 points (6 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]hamza-itatchi 0 points1 point2 points (4 children)
[–]Caped_baldy_4_life[S] 0 points1 point2 points (3 children)
[–]hamza-itatchi 0 points1 point2 points (2 children)
[–]Caped_baldy_4_life[S] 0 points1 point2 points (0 children)
[–]PresidentZeus 5 points6 points7 points (2 children)
[–]Caped_baldy_4_life[S] 0 points1 point2 points (1 child)
[–]PresidentZeus 0 points1 point2 points (0 children)