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 Java Basics Perfecting the Prototype Looping until the value passes

How do I write a do while loop?

Hi everyone,

I'm having trouble incorporating a do while loop for this code. If anyone of you could help me figure it out, I'd really appreciate it! :)

Thanks,

2 Answers

Hi Sami,

I have written an example of a do while loop below, if you have any questions about its structure or do while loops in general then feel free to ask me them.

do {
    // Do something here
} while(i > 50); // This is where your condition goes.

-Luke

Thanks, Luke! I was able to figure it out. I was wondering if you could help me figure out what's wrong with this console.printf function?

console.printf("Because you said <response>, you passed the test! \n\n");

Treehouse keeps saying that I need to use console.printf with a formatted string with the response?

Thanks again for all the help!

Alexander Kuvshinov
Alexander Kuvshinov
870 Points

Sami,

console.printf("Because you said %s, you passed the test! \n\n", response);