Basic data types in Java 8

Source: Internet
Author: User

1) Four types of integers (byte, short, int, long): byte:8 bits, used to represent the smallest data units, such as data in files, -128~127 short:16 bits, rarely used, -32768 to 32767 int:32 bits, most commonly used, -2^ 31-1~2^31 (2.1 billion) long:64, sub-common matters needing attention: int i=5;    5 is called direct volume (or literal), which is the constant written directly.    The integer number polygon defaults to type int, so L or L are appended to the long data defined.    Variables that are less than 32 digits are calculated as the int result. The strong-to-transmitting math operator has high precedence. See examples in constants and variables.

2) Two types of floating-point numbers (float, double): float:32 bit, suffix F or f,1 bit sign bit, 8-bit exponent, 23-bit valid mantissa. Double:64 bit, most commonly used, suffix D or d,1 bit sign bit, 11-bit exponent, 52-bit effective tail Note: Binary floating-point number: 1010100010=101010001.0*2=10101000.10*2^10 (2-square) =10 10100.010*2^11 (3-time square) =. 1010100010*2^1010 (10-second) Mantissa:.  1010100010 index: 1010 Radix: 2 The floating-point literal defaults to a double type, so adding F or f;double type after the defined float data is not a suffix, but be sure to write D or x.x float in the decimal calculation    The accuracy is not long and the number of significant digits (Mantissa) is short.    The range of float is larger than the long index can be large. Floating-point numbers are imprecise and cannot be accurately compared to floating-point numbers.

3) a character type (char): Char:16 bit, is an integer type, 1 characters enclosed in single quotation marks (can be a Chinese character), using Unicode codes to represent characters, 0~2^16-1 (65535).    Caveats: cannot be 0 characters. Escape character: \ n line break \ r enter \ t return \ \ "double quotation mark \ \ to denote a \ Two char middle with" + "connection, the inner first to convert the character to int type, then add operation, Char is the number of the essence! Binary, when displayed, is displayed as a character by "processing".

4) A Boolean type (Boolean): True and false false.

5) type conversion: char--> automatic conversion: byte-->short-->int-->long-->float-->double cast: ① will lose precision, produce The digits after the decimal point are all discarded. ② easily exceeds the range of values.

6) Memory: 8 bits: Byte (byte) 16 bits: Short (shorter integer), char (character) 32 bits: Int (integer), float (single/floating point) 64 bits: Long (length integer), double (dual precision Type) Last: Boolean (Boolean type

BOOL is the keyword in C evaluates to True and False
BOOL is a Boolean type, with a value of TRUE and false it is defined in the header file as a typedef int BOOL;
Boolean is defined in the header file as a typedef unsigned char BOOLEAN, which is the unsigned character type;
Boolean is the same type used in Java with the same method as bool

Basic data types in Java 8

Related Article

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.