This has more advantages, because less memory is used and less garbage collection is needed, which both also increase the execution time. Loops First of all, make sure that the variable for the loop counter is a local int variable, no instance or class variable. And the decrement operator directly with the comparison is faster than a special increment operation. Often, loops are used to move array elements to another array. Methods should be declared private, final or static if possible.
Public methods do only make sense if they are called from other classes.
Private methods can only be called from the same class, final methods cannot be inherited and static method cannot access instance variables. Operator Using the . operator to access objects and instance variables also takes time.