Basic data types and operators for Java

Source: Internet
Author: User

Basic data types

Basic data types

 1 byte (byte) = 8 bit (bit)

    • Integral type. BYTE (8-bit) short (16-bit) int (32-bit) long (64-bit)
    • Floating point type. Float (single precision. 32-bit) double (doubles). 64-bit)

Add F to the value followed by the float type, without representing the double type

Example: 3.14 for double,3.14f on behalf of float

    • Character type. char (16-bit)

Char in Ps:java is 16 bits, which is 2 bytes, and char in C is 8 bits, which is 1 bytes

    • Boolean type. Boolean (1-bit)

Type conversions

  

    

    Turn left to right, convert directly

Turn right to left, cast

Operator

Divided

Unary operator, two-ary operator, ternary operator

    • Unary operators: + + (self-increment)-(self-subtraction)-(minus) + (plus sign)! (non) ~ (bitwise negation) ...
    • Binary operators: +-*/% + = = *=/=%= && (with) & (bitwise VS) | | (OR) | (bitwise OR) &&= | | = = (Assignment) = = (judging if equal)! = > >= < <=
    • Ternary operator:?:

Priority level

Attention:

Three shift operators

>>: Value Right Shift
<<: Value left Shift

>>>: Unsigned Right shift, ignore sign bit, empty 0

Basic data types and operators for Java

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.