which of the following two snippets is faster, assuming list is an ArrayList.
for(int i=0; i<list.size();i++){...}
or
int count = list.size();
for(int i=0; i<count;i++){...}
Also, does the optimization (if any) carry to Android's ArrayAdapter?
int sCount = mAdapter.getCount();
CLARIFICATION
in the for-loop does the compiler call list.size() each time or does it call it once and use it subsequently.
Note that each call to list.size() will actually go and count the items. So that's the essence of the question.
ioutside of the loop, ala C. Might save you a few picoseconds. Seriously though, they should compile to the same thing.ArrayListas theListimplementation, your statement is false.