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!
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

Lee Preslan
Android Development Techdegree Student 3,594 PointsCensoring Words - Using String Equality
In Java Basics under the exercise titled "Censoring Words - Using String Equality", Craig uses { } marks while typing out a command in the exercise. Why were the { } marks used in the spots that they were placed in the example below? Thank you.
if (noun.equals("dork")){ console.printf("That language is now allowed. Exiting. \n\n"); System.exit(0); }
2 Answers

Brandon DeJesus
2,994 PointsHe uses the {} because that is the proper syntax for the IF statement he used. It kind of looks confusing when it is all on one line like that. However, this is the proper method of using an IF statement. Look below at how I spaced out the wording and it should make more sense. Hope this helps.
if (noun.equals("dork")){ console.printf("That language is now allowed. Exiting. \n\n"); System.exit(0); }
if(insert argument){//if argument is true go into statements statements statements }//finished

Fahad Mutair
10,359 Pointshi Lee Preslan , in if statement with more than 1 statement you have to use {} in it's body like this
if (noun.equals("dork")){
console.printf("That language is now allowed. Exiting. \n\n");
System.exit(0);
}
but with 1 statement inside if body can be like this , in this case you don't really need those {}
if (a==b) System.out.print("a equals b");
Lee Preslan
Android Development Techdegree Student 3,594 PointsLee Preslan
Android Development Techdegree Student 3,594 PointsHi Brandon DeJesus, So the { goes after the if statement and argument that's inserted and then } after the final statement?