java的基本数据类型(4类8种)

本文详细介绍了编程中的基本数据类型,包括整型(byte,short,int,long),浮点型(float,double),字符型(char)和布尔型(boolean),以及它们的取值范围、占用字符数和类型之间的转换规则。

一  总括

整型:byte、short、int、long

浮点型:float(单精度)、double(双精度)

字符型:char

布尔型:boolean

二 取值范围

byte :-128~127(2的7次方)
short :-32768~32767(2的15次方)
int :-2147483648~2147483647(2的31次方)
long :-9223372036854774808~9223372036854774807(2的63次方)

float::3.402823e+38~1.401298e-45
double:1.797693e+308~4.9000000e-324

char:

boolean : true ·false

三 占用字符

byte :1
short :2
int :4
long :8

float::4
double:8

char:2

boolean : 

四 类型转换

可自动转换的如下所示.

byte :
short :byte
int : byte·short ·char
long :byte·short ·int·char

float::byte·short ·int·long·char
double:byte·short ·int·long·float·char

char:

boolean : 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值