If/Else Blocks and Curly Brackets - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

If/Else Blocks and Curly Brackets

pleb1606pleb1606 Posts: 4Member
Are curly brackets required on every if/else block? I have seen if/else code without them. Why?


  • sunlotussunlotus Posts: 55Member

    Some use it by convention, easier to read. Just how they make classes names in java start with capital letters, though it's not a must

  • thakur66thakur66 BangalorePosts: 5Member

    Curly Brackets are not mandatory in every if/else block, how ever in order to make your code more readable (i.e; easily distinguish the nested if else block of code ) you should use the curly brackets.

Sign In or Register to comment.