基本数据类型对应字节码

【零】布尔型
[u]boolean boo = true;[/u]
对应字节码
[u]0: iconst_1
1: istore_1[/u]

【①】byte型:
byte m = 1;
对应的字节码:
0: iconst_1
1: istore_1

【②】int型:
int m = 1;
对应字节码
[u]0: iconst_1
1: istore_1[/u]

【③】short型:
short m = 1;
对应字节码
[u]0: iconst_1
1: istore_1[/u]

【④】long型:
long m = 1;
对应字节码:
0: lconst_1
1: lstore_1

【⑤】char型:
char m = 'a';
对应的字节码:
0: bipush 97
2: istore_1

【⑥】float型:
float m = 1.0f;
对应的字节码:
0: fconst_1
1: fstore_1

【⑦】double型:
double m = 1.0;
对应的字节码:
0: dconst_1
1: dstore_1

可以发现boolean,int,short,byte都是已iconst开头,这说明这几个类型在jvm看来都是同一个类型。没多大区别
解释一下命令的大致意思:
Tconst:将常量加载到操作数栈中。后面的数字相当于索引。T可替换为i,l,f等等
Tstore:将一个数值从操作数栈存储到局部变量表中
其中char的bipush 97就是把常量97加载到操作数栈中,供后面操作使用。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值