for( int i = 0; i < collection.size(); i++ ) { … } 优化后: for( int i = 0, n = collection.size(); i < n; i++ ) { … }