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 While Loops

Jacob Klug
Jacob Klug
469 Points

Why did craig put this symbol } after he wrote console.printf(" next slide");

Little confused on what these bracets do { } and why craig put a closing braket } after he wrote console.printf(" Next Slide");

Nathan Huls
Nathan Huls
5,709 Points

I'm also confused by this. I understand the brackets open/close a block of code, but why is this block of code opened with a { and then closed three times?

2 Answers

Vithushan Elangovan
Vithushan Elangovan
2,740 Points

One bracket is for closing of the while loop, another is the closing bracket for the public static void (also known as the main method/function) line and another for the class (the public class line).

Raffael Dettling
Raffael Dettling
32,998 Points

I think you mean the closing } of the main fucntion the while loop is already closed^^

Raffael Dettling
Raffael Dettling
32,998 Points

You can see that on 6:19 both braces are highlighted yellow^^