Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,997 Points

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

Raffael Dettling
Raffael Dettling
32,997 Points

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