增量逻辑无法正常工作

dev*_*per 1 java for-loop

我必须根据外部循环增加内部循环,但我的逻辑是失败的.

int size = currencyList.size();

for (int i=0, j=1; i<size; i++) {
    CurrencyVO currencyVO = currencyList.get(i);
    obj1[i+2] = currencyVO.getStrDerivedRefDT();
    // CurrencySetupVO cureccyCodeDes = currencyExchList.get(k);

    //if (i==0)
    obj3[0]=currencyVO.getStrCurrencyCode();
    //if (i==1)
    obj3[1]= currencyVO.getStrCurrencyDesc();
    //if (k<size) {
    obj3[i+2]=currencyVO.getStrExchRate();
    //}
    data.put(j,obj3);
    data.put(0,obj1);
    if (i==31) {//***Here for every i=31,62,93 etc J has to increment***
        j++;
    }
}
Run Code Online (Sandbox Code Playgroud)

我该如何实现呢?

Sur*_*tta 6

对于每个i = 31,62,93等,j必须递增

那你的逻辑应该是

 if(i!=0 && i%31 ==0){//***Here for every i=31,62,93 etc J has to increment***
                j++;
            }
Run Code Online (Sandbox Code Playgroud)

那个%是模运算符