Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I wrote same to this.dest the sortStr is better than mine.
Length of an array is a public final int, so no calculation is done.
see here
http://docs.oracle.com/javase/specs/jls/se7/html/jls-10.html#jls-10.7
really?learn it!
That is not true.
i<length
and
i<arr.length
have exactly the same cost.
The difference would be, when comparing to collection size, such as ArrayList and using .size() method, but here it doesn't matter.
for (int i=0; i<arr.length; i++)
Calculate the length in the cycle, is not efficient
int sum = 0;
int length = arr.length;
for (int i=0; i<length; i++) {
sum += (i % 2 == 0) ? arr[i] : arr[i] * arr[i];
}
return sum;