If you want to set that value to zero in a single line you can do it this way: obj1.value = obj2.value = 0;
If you need to modify that value in some other ways you need can't do it at the same time but a human won't be able of telling the difference.
Notice: also obj1.value = obj2.value = 0; applies 0 to obj2 first and then to obj1
Right now i have an object array and a while and a for that checks the elements for the value <= 0
but i have no idea how to exit that loop when all elements are 0 or less than 0
If you want to exit the while when all of them are equal to zero, add a second loop for checking:
1 2 3 4 5 6 7 8 9 10 11 12 13
while ( !isZero )
{
// first for ...
isZero = true; // assume all of them are zero
for(int i = 0; i < v; i++)
if ( number[i].getCurrentValue() != 0 ) // one of them is not zero ( you don't really need the '!= 0' part )
{
isZero = false; // continue the whilebreak; // exit from the for
}
}
When you find one not equal to zero, isZero will be set to false ( line 10 )
You can't know the values of all your objects at the same time so you cannot check if they are all equal to zero. But you can check if not all of them are equal to zero