Java for Reading Notes, java for Reading Notes

Source: Internet
Author: User

Java for Reading Notes, java for Reading Notes

Expression puzzles

 

"Odd

When the remainder operation is performed, a non-zero result is returned. It has the same positive and negative symbols as the left operand.

Zero puzzles

Avoid using float and double where exact answers are needed. For currency operations. Use int, long, or BigDEcimal.

Long division

When you are building a large number, you must never let it go-he is a silent killer.

If you are not sure, you can use the long operation to execute the entire computation.

Preliminary questions

In the literal length of the long type, the L must be capitalized;

Multiple Transformations

If the initial numeric type is signed, the symbol extension is executed. If it is a char, the 0 extension is executed no matter what type he wants to convert. Do not use the composite value assignment operator for byte, short, or, char.

Character puzzles

 

To convert a char array to a String, call the String. valueOf (char []) method.

When using string Concatenation Operators, we always enclose extraordinary operators in parentheses. (+ Operator priority is greater than =)

, Do not use Unicode escape characters unless necessary.

Loop puzzles

 

Do not assign values to the same variable more than once in a single expression.

An exception

 

Never use return break to exit the finally statement block.

To handle any errors that may be thrown in the finally statement block, rather than spreading them.

Do not use exception control loops. Only Exception conditions should be used.

CATEGORY puzzles

 

Each static field shares a single copy of its class and all its sub-classes.

Never use an expression to identify a static method. Do not hide static methods.

The instanceof operator is defined as false if its left operand is null.

Using a variable to create an instance

Other puzzles

Do not add 0 to the front of an integer literal constant. This will change it to an octal value.

 

 

 

 

 

 

 

 

 

 

 

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.