Java Java Basics Perfecting the Prototype Parsing Integers

Michael Greig
seal-mask
.a{fill-rule:evenodd;}techdegree
Michael Greig
Front End Web Development Techdegree Student 9,694 Points

What're the rules around where you put your curly braces?

Hi there!

Just a quick one from the previous lesson...

Is it necessary to put a closing curly brace on a new line? Why is it not added at the end of the last line of code, like normal braces?

if (age<13) { //Insert exit code console.printf("Sorry you must be at least 13 to use this program. \n"); System.exit(0); }

Thanks,

Michael

1 Answer

Kourosh Raeen
Kourosh Raeen
23,728 Points

Hi Michael - Take a look at the Google Java Style Guide regarding braces:

https://google.github.io/styleguide/javaguide.html#s4.1-braces