Home > Java > javaTutorial > body text

What are the java data types?

清浅
Release: 2020-09-08 09:49:33
Original
110147 people have browsed it

The data types in Java are divided into two categories: basic types and reference types. Basic types include int, float, double, char, boolean and other eight types. Reference types include classes, arrays and interfaces. type.

What are the java data types?

【Recommended course: Java Tutorial

java data types include:

1. Basic data types

Simple data types are built-in data that cannot be simplified Types, defined by the programming language itself, represent real numbers, characters, and integers.

There are eight basic data types in Java, which are the following types:

Data type Description Occupied bytes Value range Default value
int Integer type, used to store integers 4 bytes -2147483648~2147483647 0
byte The smallest data type in Java 1 byte -128~127 0
short Short integer 2 bytes -32768~32717 0
long Long integer 8 bytes -2^63~2^63-1 0L
float Floating point type, used to store numbers with decimal points 4 bytes / 0.0f
double Double precision floating point type, used to store numbers with decimal points 8 Bytes / 0.0d
char character type, used to store a single character 2 bytes 0~65535 empty
boolean Boolean type, used to determine true or false 1 byte There are only two values, namely true and false false

Note: One byte is equal to 8 bits (bit)

What are the java data types?

2 , Reference data type:

In Java, reference type variables are very similar to C/C pointers. A reference type points to an object, and a variable pointing to an object is a reference variable. These variables are assigned a specific type when declared, such as Employee, Puppy, etc. Once a variable is declared, its type cannot be changed.

There are three reference types in Java, namely classes, arrays, and interfaces. The default values ​​of these reference types are null

What are the java data types?

Basic The difference between types and reference types:

The difference between basic data types and reference types is mainly that basic data types are allocated on the stack, while reference types are allocated on the heap

Summary: The above is the entire content of this article, I hope it will be helpful to everyone.

The above is the detailed content of What are the java data types?. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!