when do I need to put in curly brackets? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

when do I need to put in curly brackets?

22nd Jun 2016, 10:36 AM
Brodie Flynn
3 Answers
+ 5
When there is more then one statement in the if-else. You can skip the { } when there is just one statement, but it is recommended to always put the brackets. It makes the code more readable.
22nd Jun 2016, 11:39 AM
James Flanders
+ 1
You put in curly brackets every time you start a new method and you close every time you end the method. The same applies when you start and end a class, a loop, a condition. Curly brackets are how you know that the code separated.
3rd Jul 2016, 7:28 AM
Fotis Aronis
Fotis Aronis - avatar
0
it is the seperator for that particular sequence
29th Jun 2016, 3:21 PM
janu akshitha
janu akshitha - avatar