当前位置:网站首页>i++与 ++i 的区别
i++与 ++i 的区别
2022-07-30 05:45:00 【zpv2jdfc】
首先看一段代码
int i=1,j=2;
int a = i++;
int b = ++j;
上述代码对应的字节码
0 iconst_1
1 istore_1
2 iconst_2
3 istore_2
4 iload_1
5 iinc 1 by 1
8 istore_3
9 iinc 2 by 1
12 iload_2
13 istore 4
从4、5行号的指令可以看出,i++是先将i从局部变量表取出到操作数栈中,然后将局部变量表中的i加1.
++j对应9、12行号的之指令,是先将局部变量表中的j加1,然后取出到操作数栈中。
jdk1.8 jvm规范中对IINC指令的描述:
Description
The index is an unsigned byte that must be an index into the local variable array of the current frame (§2.6). The const is an immediate signed byte. The local variable at index must contain an int. The value const is first sign-extended to an int, and then the local variable at index is incremented by that amount.
边栏推荐
- The types of data structures and MySQL index
- 2021-09-19 集成学习TASK2
- 原型模式(Prototype):Swift 实现
- AAcell五号文档室——跨平台文件传输的小室一间一间的
- 什么是过拟合、欠拟合现象以及如何缓解?
- R - GIS: how to use R language implementation of GIS geospatial analysis and model prediction
- 昆仑通态屏幕制作(连载1)---接触篇
- 生产力工具分享——简洁而不简单
- Redis publish/subscribe
- R-GIS: 如何用R语言实现GIS地理空间分析及模型预测
猜你喜欢
2021年软考中级过关
How does MATLAB display nii file slice information in the image?
探究make_shared效率
昆仑通态屏幕制作(连载3)---基础篇(按钮串口发送)
昆仑通态屏幕制作(连载5)---基础篇(串口接收,文本与灯显示)
十、Kotlin基础学习:1、延迟加载;2、异常处理;3、使用 throw 主动抛出异常;4、自定义异常;
七、Kotlin基础学习:1、创建类;2、构造函数;3、继承;4、封装;5、抽象类;6、接口;7、嵌套类;8、内部类;9、枚举类
MySQL data types and footprint
QT连载2:基于QT和STM32H750的LORA试验平台(1)
Atmospheric particulate matter PMF source analysis
随机推荐
Application of remote sensing, GIS and GPS technology in hydrology, meteorology, disaster, ecology, environment and health
八、Kotlin基础学习:1、数据类;2、单例;3、伴生对象;4、密封类;
2021-09-19 集成学习TASK2
【江科大自化协stm32F103c8t6】笔记之【入门32单片机及GPIO初始化参数配置】
边境的悍匪—机器学习实战:第十六章使用RNN和注意力机制进行自然语言处理
CNN经典模型发展进程
Generalized Focal Loss 论文阅读笔记
CPU的三种工作模式:实模式、保护模式、长模式
openssl 1.1.1编译语句
【正点原子】IIC的学习与使用(未完...)
[Getting C language from zero basis - navigation summary]
边境的悍匪—机器学习实战:第十章 Keras人工神经网络简介
Redis publish/subscribe
Jdbc & Mysql timeout analysis
【江科大自化协stm32F103c8t6】笔记之【入门32单片机及TIM定时中断初始化参数配置】
边境的悍匪—机器学习实战:第十二章 使用TensorFlow自定义模型和训练
TCP建立连接的过程
Kaggle-M5
遥感、GIS和GPS技术在水文、气象、灾害、生态、环境及卫生等应用
User password encryption using Bcrypt instead of MD5, SHA1 and SHA256