Home > Java > JavaBase > What are the basic data types in Java

What are the basic data types in Java

王林
Release: 2019-11-12 10:44:49
Original
12313 people have browsed it

What are the basic data types in Java

1. Four integer types (byte, short, int, long)

byte: 8 bits, used to represent the smallest data unit , such as the data in the file, -128~127

short: 16 bits, -32768 ~ 32767

int: 32 bits, -2^31-1~2^31 (2.1 billion)

long: 64 bits

2. Two floating point types (float, double)

float: 32 bits, suffix F or f

double: 64 bits, the most commonly used, suffix D or d

3. A character type (char)

char: 16 bits, an integer Type, 1 character enclosed in single quotes (can be a Chinese character)

Note: It cannot be 0 characters.

Escape characters: \n Line feed \r Carriage return \t Tab character \" Double quotation marks \\ represents a \ Two characters char are connected with " " in the middle. The characters are first converted to int type internally, and then For addition operations, char is essentially a number! Binary, when displayed, is "processed" and displayed as characters.

4. A Boolean type (boolean)

true and false

5. Type conversion

char--> Automatic conversion: byte-->short-->int--> ;long-->float-->double                                                                                                                                                                                                           through Exceeding the value range

Recommended tutorial:

Java tutorial

The above is the detailed content of What are the basic data types in Java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template