Four types of Java, eight basic data types

Source: Internet
Author: User
Tags float double

There are eight basic java data types, just remember. All of these are references.

Four types of Java, eight basic data types

Class 1: integer byte short int long
Category 2: Float double

Category 3: Logical Boolean (only two values can be true or false)

Class 4: character char

The data that can be directly allocated memory in the stack is the basic data type.
Reference data type: refers to the reference of data in the stack, but its object is in the heap.
To learn java well, you must know where all kinds of data are stored in the memory.
A good understanding of memory can help you analyze programs.

Byte:
Boolean 1/8
Byte byte type 1
Char character type 2 one character can store one Chinese Character
Short short integer 2
Int Integer type 4
Float floating point type (single precision) 4
Long Integer 8
Double double type (double) 8

The default Integer type in Java is int. To define it as float, add L or L to the value;
The default floating point type is double-precision floating point. To define the float type, add f or F to the value.

A single byte is equal to 8 bits, and a single byte is equal to 256 bits, that is, a total of 128 bytes from-127 to 256.
KB is Kbytes
Bytes means byte!
K means a thousand, because the computer is computed in binary format, and the value of 10 "1" is exactly 1024.
1111111111 (Binary) = 1024 (decimal)
1 bytes (bytes) = 8bit (BIT)
An English letter or an Arabic number is a character and occupies one byte.
A Chinese character is two characters, occupying two bytes.
Generally, the size is bytes, and the upper-case "B" indicates that the network speed is bit. Note that the lower-case "B" is used ".
For example, an object contains 8 Mbytes
For example, the download speed of my files is kb/s, that is, 2 Mbit. This is usually the rate at which we access the Internet through broadband.

Automatic conversion of Basic Data Types

Byte-> short, char-> int-> long
Float-> double
INT-> float
Long-> double

Px

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.