在许多情况下,大多数情况下,当您循环遍历数组并向元素分配值时,可以使用后自增运算符。这是否被认为是一种好习惯。
例如,在下面的复制代码中,哪一个更好。
int [] to_assign;
int [] to_include;
int [] from_assign;
// Version 1
int count = 0;
while(i<<some_value>){
  if(to_include[i]==1)
     to_assign[count++] = from_assign[i];
}
// Version 2
int count = 0;
while(i<<some_value>){
  if(to_include[i]==1)
  {     
      to_assign[count] = from_assign[i];
      count++;
  }
}