I came across this blog post on optimizing PHP and thought some of this is applicable to Java also and tried it.

Here is one of them:

Consider the 2 for loops below:


for (long i = 0; i < 1000000000; ++i) {


for (long i = 0; i < 1000000000; i++) {

Q:Which one is faster?
A:First loop is faster.

A:First loop uses a pre increment operator where as the second loop uses a post increment operator. Pre increment operator is faster than post because post increment operation requires a copy of the variable to be made whereas pre incrementing does not require a copy to be made.