File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes using a++   and  a+1 ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using a++   and  a+1 ?" Watch "using a++   and  a+1 ?" New topic

using a++ and a+1 ?

Anto Telvin
Ranch Hand

Joined: Aug 12, 2008
Posts: 113
hi all
why it is saying that a++ is faster than a+1 ?

thanks in advance

Anto Telvin Mathew<br />Many of the life failures are people who did not realize how close they were to success when they give up. EDISON
Bupjae Lee
Ranch Hand

Joined: May 14, 2007
Posts: 107
SUN JDK javac 1.6.0_07 compiler generates bytecodes like below:

It is true that a++ is slightly faster than a=a+1, but I think there are not that much difference.
Anto Telvin
Ranch Hand

Joined: Aug 12, 2008
Posts: 113
It is sorta covered in the JavaRanch Style Guide.
subject: using a++ and a+1 ?
Similar Threads
Are there any Parsi guys on JR?
Portal and portlet developement forum
count yourself in javaranch#~
How many rotations...
0 or 1