-1
int[] material = {6255,6255,5003};
int sumQuan = 0;
int []quantity = {6,5,1};
String []calc = {"1","1","0"};
int len = material.length;
int a = material[0];
for(int i = 0; i < len; i++)
{
if(a==material[i] && calc[i]=="1")
{
sumQuan = sumQuan+quantity[i];
}
else if(calc[i]=="0"){
sumQuan = 0;
}
else
{
sumQuan = quantity[i];
}
System.out.println(sumQuan);
}
我想返回11,0,但它返回6,11,0。使用另一個陣列的條件從1個陣列中添加數字
NOOOOOOO ...不是'=='而不是'equals':___( – Maroun