Built-in types in Java

Source: Internet
Author: User

Common types, and a brief introduction

Http://wenku.baidu.com/view/f5a2b56825c52cc58bd6bee5.html for 8 Basic Data Types

Char, boolean, byte, short, int, long, float, and double. The numeric type can be divided into byte, short, int, long, float, and double types.

Basic type and corresponding packaging class (int Integer relationship)

Basic Conversion Diagram:

Storage Format of float and double: http://blog.csdn.net/zcczcw/article/details/7362473

Float. MIN_VALUE and Double. MIN_VALUE respectively indicate the smallest positive numbers that float and double can represent. That is to say, the value Float between 0 and ± float. MIN_VALUE cannot be expressed, and the value Double type between 0 and ± double. MIN_VALUE cannot be expressed. This is not surprising because the values in these ranges are beyond their precision ranges.

1. integers without a character suffix are of the int type by default. Floating-point numbers without a character suffix are of the double type by default.
2. If the value of an integer exceeds the range that can be expressed by the int type, the suffix "L" must be added (case-insensitive. We recommend that you use uppercase letters, because the lower-case L and Arabic numerals 1 are easily confused), expressed as long.
3. All integers and floating-point numbers with the "F" (case-insensitive) Suffix are float; All integers and floating-point numbers with the "D" (case-insensitive) Suffix are double.
4. the compiler checks the values of byte, short, int, long, float, double, and char variables during compilation. If the values exceed the value range, an error is returned.
5. int values can be assigned to all numeric variables; long values can be assigned to long, float, and double variables; A float value can be assigned to a float or double type variable. A double value can only be assigned to a double type variable.

Integers without a character suffix are of the int type by default. Floating-point numbers without a character suffix are of the double type by default.

If the value of an integer is beyond the range that can be expressed by the int type, the suffix "L" must be added (case insensitive, it is recommended to use uppercase letters, because lowercase L and Arabic number 1 are easily confused), expressed as long

Float: 32 = 1 + 8 + 23 (symbol bit + index bit + tail bit)

Automatic matching of specified parameter types

Match the type closest to the upper layer according to the conversion sequence.

Automatic match of Variable Parameter List

If there is no exact type match, there are multiple high-level types, which will be ambiguous.

Some methods

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.