Home > Java > javaTutorial > Introduction to java data types

Introduction to java data types

PHP中文网
Release: 2017-06-20 10:10:46
Original
1595 people have browsed it

Data type

Basic data type

  • Numeric type

  • Integer type (byte, short, int, long )

  • Character type (char)

  • Boolean type (boolean)

Reference data type

  • Class

  • Interface

  • Array

Note: For example, the String type is also a class type.

Features

1. Conceptually
Basic type: variable name points to a specific value
Reference type: variable name points to the memory address of the data object
2. From the perspective of memory construction
Basic type: Java will allocate memory space to the variable immediately after it is declared
Reference type: No memory is allocated when the variable is declared, but a memory address is stored
3. From the aspect of use
Basic type: When using, you need to assign a specific value, and when judging, use the "==" sign
Reference type: When using, you can assign null. When judging, use the equals method

Basic data type byte length

##short2byte(bit)1char2boolean1float4double8
Data type byte
long 8
int 4

NoteThe char type in java is stored in Unicode encoding. Can store Chinese characters.


If there is anything wrong, you are welcome to point it out and we can learn together! !

The above is the detailed content of Introduction to 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