Add parentheses after Java if

Source: Internet
Author: User

There is an if judgment in the project that does not increase the parentheses, but there is a lot of logical processing behind it. This is not standard, but also cause the changes in the code will cause unnecessary trouble, so I will all the code over my hand, have been modified. Like what:

if (A) result = "Hello";

Do something

Modified to:

if (A) {result
 = "Hello";
}
Do something

Concrete Project Code screenshot:
(in fact, it's also a violation of a method, preferably only a return principle)

In revising this question, I am afraid that the changes appear to be superfluous, the code appears to be sloppy, so I went to know and Oschina on the search, to see if the other people on whether or not to increase the brackets after the view that most of the results are: best to Add.
The reasons are broadly as follows:
1/For code specification, you should enlarge parentheses after if
2/If you need to declare a temporary variable after if, you need to add curly braces, otherwise the compilation will not pass
3/Have a friend said that Google's programming specification is to say if after must add (do not know true or false, also did not go to investigate)
4/Someone said that in order to modify the code after no ambiguity

Conclusion: In Java programming, you need to enlarge the parentheses after the IF. Conventions are better than configurations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.