为什么算术赋值运算符效率更高? [英] Why are arithmetic assignment operators more efficient?

查看:88
本文介绍了为什么算术赋值运算符效率更高?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

速记Java算术运算符的一个示例是a=a+4;a += 4;

An example of thee shorthand Java Arithmetic operator is a += 4; for a=a+4;

在Java 2的《完全参考》中,Herbert Schildt提到它们比同等的Java运行时系统更有效地实现"

In The Complete Reference, Java 2, Herbert Schildt mentions "they are implemented more efficiently by the Java run-time system than are their equivalent"

是什么使它的实现比a=a+4;

推荐答案

在任何给定的执行环境中,只有微基准可以确认或拒绝作者的主张.

Only microbenchmarks can confirm or reject the author's claim in any given execution environment.

在现代JVM上,这两个版本很有可能表现出相同的性能.

On a modern JVM, it is more likely than not that the two versions will exhibit identical performance.

P.S.如果书名中的"2"与"Java 2"中的一样,我强烈建议您购买一本最新的书!

P.S. If the "2" in the book title is as in "Java 2", I'd strongly recommend getting a more up-to-date book!

这篇关于为什么算术赋值运算符效率更高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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