普通码农 2020-04-04 20:13 采纳率: 100%
浏览 1108
已采纳

java编译后int a=true

代码如下:

public class LocalVariablestTest {
    private int count = 0;

    public static void main(String[] args) {
        LocalVariablestTest test = new LocalVariablestTest();
        int num = 10;
        for (int i = 0; i < 10; i++) {
            int a=i;
        }
    }

}

使用idea直接打开编译后的class文件,发现 int num = true;

package com.lazydsr.study.test;

public class LocalVariablestTest {
    private int count = 0;

    public LocalVariablestTest() {
    }

    public static void main(String[] args) {
        new LocalVariablestTest();
        int num = true;

        for(int i = 0; i < 10; ++i) {
        }

    }
}

这是为啥?实在搞不懂了,求助
没有C币,见谅

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-04-04 21:10
    关注

    num在下文中没有使用,所以被优化了,并且反编译器无法还原被优化的代码

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效