Java Data types

Source: Internet
Author: User

Java data Types

The data types in Java can be divided into two categories, reference types (reference types), and basic types (primitive types), with reference to the most recent definition of the Java Official document drawing type diagram below

Summarize the points I think are important in each of these types

Basic type (primitive types)
    • Integer: Used to denote a number without a mouse part, allowed to be negative, usually the most common type of int, byte and short are mainly used for the underlying file processing
    1. The scope of an integral type in Java is independent of the Java Code's operation
    2. Long-shaped suffix l or l; hexadecimal value has a prefix of 0x or 0X; octal has a prefix, starting with Java7 prefix 0b or 0B to write binary numbers
    3. Java does not have any unsigned unsigned form of int,long,short,byte type, Java practices increase the platform can be executed but sacrificing performance
    4. The char type is originally used to represent a single character, and now the Unicode character may be a char value or two

    • Floating point: Floating-point types have two double and float,double (64-bit) numeric precision is twice times the value of float (32-bit), most applications use the float
    1. FLOAT: Storage requirements 4 bytes, value range: ±3.40282347e+38f, 6-7 digits of effective digits
    2. Double: Storage requirement 8 bytes, value range approximately ±1.79769313486231570e+308 significant number of digits is 15 bits
    • Operation symbols for integral type

    1. NullPointerException exception is thrown when unpacking a null reference
    2. ArithmeticException exceptions are thrown when using 0 as the denominator for division operations
    3. OutOfMemoryError exceptions may be thrown when using the ++,--operator
    • operator of floating-point type

    1. When the two-dollar operator has at least one object that is a floating-point number, a floating-point operation is performed
    2. If at least one of the two-dollar operators is a double, the 64-bit operation is performed, and the value is first promoted when the other object is not a double
    3. Any value of a floating-point type can be converted to any number type, but there is no forced type conversion between Boolean
    4. NullPointerException exception is thrown when unpacking a null reference
    5. OutOfMemoryError exceptions may be thrown when using the ++,--operator

Java Data types

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.