Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java For Loops

Aditya Sheode
Aditya Sheode
1,291 Points

1 bottle of milk on the wall

I wanna go the other way round like 1 bottle of milk then it becomes 2 etc etc but it wont run and im not getting an error

import java.io.Console; import java.util.Random;

public class Milk {

public static void main(String[] args) { Console console = System.console();

for (int i = 0; i > 99; i++){
  console.printf("%d bottles of Milk on the wall....%n" , i);

}

} }

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! There's a small logic flaw in your loop. You start i at 0 and then you increment i after an iteration. Those parts are fine. It's the middle part that's causing the problem. You say to do this while i is greater than 99. So it never runs. Try changing that to run while i is less than 99 :smiley: