Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

a java program block starts with an open brace ({) and ends with a closing brace (}), right?

Asked by Kunal Jha Oct 10, 2022 1.2K views 1 answer
Share

About this question

Should curly braces be on their own line or not? What do you think about it?

if (you.hasAnswer()) {
    you.postAnswer();
} else {
    you.doSomething();
}
or should it be
if (you.hasAnswer())
{
    you.postAnswer();
}
else
{
    you.doSomething();
}
or even
if (you.hasAnswer())
    you.postAnswer();
else
    you.doSomething();

Please be constructive! Explain why, share experiences, back it up with facts and references.


Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.