什么是java编译器中的常量折叠? [英] What is constant folding in java compiler?

查看:213
本文介绍了什么是java编译器中的常量折叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

有没有任何概念称为恒定折叠”在java?


我遇到过Java编译器使用称为Constant Folding的东西。这是什么?它是如何影响的?

Hi I have come across line Java compiler uses something known as Constant Folding.What is this? and how Does it affect?

推荐答案

常量折叠是编译器找到包含编译时常量的表达式并将其替换为结果有效地消除了冗余的运行时计算。

Constant folding is where the compiler finds expressions that contain compile-time constants and replaces them with the result effectively removing redundant runtime calculations.

// code
static final int a = 2;
int b = 30 * a;

// folding would create
int b = 60;

这篇关于什么是java编译器中的常量折叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆