Quick programming form question..
Ok.. So I have a method that returns an array of BigIntegers.. What I get in this method is an array of unknown length, until it is passed of course. So, I create an array to store my data in (I'm determining which BigIntegers are odd in this case...) not knowing how long it needs to be.. since I have no idea how many odds are in the array until I check. So, what I did was to use a for each loop instead of a for loop with a counter that I then used to construct a new array of a proper size for the odds and then stuck all the data from the temp array into this new array. Is this bad coding practice?
Heres the code because I don't think I'm eloquent enough to get that across right...
public BigInteger[] getOdds(BigInteger[] Integers)
{
BigInteger[] temp =new BigInteger[Integers.length];
int x = 0;
for(BigInteger On : Integers)
{
if(On.mod(BigInteger.valueOf(2)).compareTo(BigInteger.ZERO) != 0)
{
temp[x] = On;
x++;
}
}
BigInteger[] output =new BigInteger[x];
for(int i = 0; i < x; i++)
output[i] = temp[i];
return output;
}

