Java log-May 30, 2016

Source: Internet
Author: User

1. Local variables must be initialized, can be initialized at the same time as defined, or can be initialized after completion.

2. Java7 new features: You can use "_" Connection between numbers, Eg:23_44_5 = 23445,0b1101_1010 = 0b11011010

3. Binary means start at 0b; octal starts at 0; hex starts at 0x.

4. The char type can be directly assigned a decimal, binary, octal, or hexadecimal literal, and the compiler automatically converts the literal to the char type.

5. The char type can also use four-bit hexadecimal to denote Unicode characters in the format char c = ' \uffff ';

6. Special rules for arithmetic operations:

1) Integer/0: throws ArithmeticException violation

2) 0.0/0.0 or 0/0.0:nan is not a number, Nan is not equal to Nan

3) integer/0.0 or floating-point/0.0 or floating-point/0: equals Infinity, denotes infinity, Infinity = = Infinity

6. Type conversions:

1) literal contains decimal binary and hexadecimal.

2) Literal integer constants are automatically resolved to type int, floating-point literals are automatically resolved to double types, and if literal integer constants are greater than int's representation range, the compiler will parse the error and need to convert the L to a long type.

3) The automatic conversion order of numeric types is the process of small precision (range of values) to large precision: int–> long–> float–> Double, byte-, short.

4) In an operation expression, all char, short, and byte are automatically converted to the int type, and the final type of the expression equals the type of the data with the highest precision in the current operation.

5) during compilation, the compiler calculates all the constant operations.

6) When assigning a literal to char, Byte, short, the compiler automatically converts the type as long as it does not exceed the range of values, and does not require manual conversions.

7) + =,-=,/= and other operations with implicit type conversion, eg:short a = 2; A + = 2; Correct, no error, no manual conversions required

7. Logical operators (operand Boolean type)

& Bit with, no short circuit

| Bit or, no short circuit

^ Bit XOR or

! Take counter

&& and, short circuit

|| Or, short circuit

8) Bit arithmetic

& Bitwise AND

| Bitwise OR

^ Bitwise XOR OR

~ Bitwise REVERSE

<< left shift, empty fill 0

>> right shift, empty fill sign bit

>>> unsigned right shift, empty 0

Usage: a ^ b ^ b = a

A & (a-1) = = 0 indicates that only one of the binary of A is 1, that is, a equals 2 n times, n is greater than or equal to 0

Java log-May 30, 2016

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.