#java
There are only 8 basic data types, just remember them. Except these are all reference types.
java
Four categories and eight basic data types
The first category: integer typebyte short int long
Second Class: Floating point type float double
Category 3: Logical typeboolean
(It has only two possible valuestrue false
)
Category 4: Character typechar
The data that can directly allocate memory on the stack is a basic data type.
Reference data type: The reference to the data is on the stack, but its object is on the heap.
If you want to learn Java well, you must know where various data are stored in memory. Having a good understanding of memory can help you analyze programs.
Bytes:
boolean
Boolean type 1/8
byte
Byte type 1
char
Character type 2 One character can store one Chinese character
short
Short integer type 2
int
Integer type 4
float
Floating point type (single precision) 4
long
Long integer 8
double Double precision type (double precision ) 8
The default integer type in java
is int type. If you want to define it as float
type, you must add l or L after the value;
The default floating-point type is also a double-precision floating point. If you want to define it as a float
type, you must add f or F after the value.
One byte is equal to 8 bits, and one byte is equal to 256 numbers, which is -128 to 127, a total of 256.
kB means kBytes Bytes means "bytes"!
K means thousands, because the computer calculates through binary, 10 1's are exactly 1024
1111111111 (binary) = 1024 (decimal)
1Bytes (word Section) = 8bit (bit)
An English letter or an Arabic numeral is one character, occupying one byte
One Chinese character is two characters, occupying two bytes.
Generally, when talking about size, Bytes is used with a capital "B". When talking about network speed, bits are used. Note that it is a lowercase "b".
Example: A file has 8MBytes
Example: The rate at which I download files is 256KB/s, which is 2Mbit. This is usually the rate at which we use broadband Internet access.
Automatic conversion of basic data types
byte->short,char -> int -> long
float -> ; double
int -> float
long -> double
Remember: Xiao Ke If you turn large or small, you will lose accuracy! ! !
Recommended tutorial: "java tutorial"
The above is the detailed content of What are the eight basic data types in java. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools