Common principles of Java development

Source: Internet
Author: User

1, Name: Package name all lowercase, the first letter of the class name all uppercase, the constant all uppercase and the underscore division, the variable uses the Hump name method
2, ternary operator:
int i=80;
String s1= String.value (i<90?90:100);
String s2= String.value (i<90?90:100.0);
The return value is not the same, S1 returns 90,S2 returns 90.0
3. When deserializing, the constructor does not execute and the final variable is re-assigned. If there is a final variable in the upgraded class that is assigned to the constructor, and the old and new versions have changed, it is likely that the result of the deserialization generated final variable value is not the same as the newly generated instance value in the process of applying the request eagerly, so the business exception is generated, in severe cases, Will affect the transaction data.
Therefore, in a serialization class, a constructor is not used to assign a value to the final variable.
4, wages are divided into performance wages and basic wages, the need for performance pay confidentiality.
Method 1: Pay transient before performance. This marks the wage category in the urban area distributed deployment capabilities, once encountering performance bottlenecks, and then want to implement distributed deployment is impossible, this method is not feasible.

5, instanceof
' A ' instanceof Character: compilation does not pass, because instance can only be used for object judgments and cannot be used for basic types of judgments.
Null instanceof String: The return value is false, and if the left operand is null, the result returns false directly and no longer evaluates to what class the right operand is. Used for (string) null instanceof String
The new date () instanceof string compilation does not pass because the Date class string does not inherit and implement the relationship, so the compile time directly error.

Common principles of Java development

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.