0
How to subtract the values in array with other values and put results back to array in java?
2 Respuestas
+ 2
I'm not exactly sure if I'm ok interpreting your question.. but i will try to help with the following code:
for(int i = 0; i < array.length; i++) {
array[i] -= valueToSubstract;
}
You can use the same way (index access) to substract one element to another separated by a fixed quantity like this:
array[i] -= array[i + 1];
(take care about logic errors e.g. a chain of substractions you didn't want to do, control this with step or for's increment section, and not to get out of bounds, control last with the for's condition section)
Excuse my english, i hope that helps you!
bye! :)
+ 2
Thanks you so much😊😊