array substracting problem
Hi All,
I need some suggestion for making elements in the same array to subtract one another. For example, if the array is int a [ ] = {b,c,d}; , then I want the output to show the value of (c-b) ,(d-b), and (d-c). I actually wrote some lines but never get the right output(the output of this code is 49,69,79,30). Please point out the reason why it does not work out or suggest a better way. Thanks.
publicclass test{
publicstaticvoid main(String[] args){
int testA[]={1,50,70,80,100};
int testCounter=0;
int testCounterTwo=1;
while((testCounterTwo+testCounter)<testA.length&&testCounterTwo>testCounter){
int testEvaluator=testA [testCounterTwo+testCounter]-testA [testCounter];
System.out.println(testEvaluator);
testCounterTwo=testCounterTwo+1;
if ((testCounterTwo+testCounter)==testA.length-1){
testCounter=testCounter+1;
testCounterTwo=testCounter+1;
}
}
}
}

