BioMatter[] returnArray = (BioMatter[]) (itemsToReturn
BioMatter[] returnArray = (itemsToReturn
    public BioMatter[] takeBioMatterMass(float pMass) {        if (pMass <= 0)            return new BioMatter[0];        List itemsToReturn = new Vector();        List itemsToRemove = new Vector();        float collectedMass = 0f;        for (Iterator iter = currentBiomassItems.iterator(); iter.hasNext()                && (collectedMass <= pMass);) {            BioMatter currentBioMatter = (BioMatter) (iter.next());            float massStillNeeded = pMass - collectedMass;            //we need to get more bio matter            if (currentBioMatter.mass < massStillNeeded) {                itemsToReturn.add(currentBioMatter);                itemsToRemove.add(currentBioMatter);                collectedMass += currentBioMatter.mass;            }            //we have enough, let's cut up the biomass (if too much)            else if (currentBioMatter.mass >= massStillNeeded) {                float fractionOfOriginal = massStillNeeded                        / currentBioMatter.mass;                BioMatter partialReturnedBioMatter = new BioMatter(                        massStillNeeded, currentBioMatter.inedibleFraction,                        currentBioMatter.edibleWaterContent                                * fractionOfOriginal,                        currentBioMatter.inedibleWaterContent                                * fractionOfOriginal, currentBioMatter.type);                currentBioMatter.mass -= partialReturnedBioMatter.mass;                itemsToReturn.add(partialReturnedBioMatter);                if (currentBioMatter.mass <= 0)                    itemsToRemove.add(currentBioMatter);                collectedMass += partialReturnedBioMatter.mass;            }        }        //Remove items from List        for (Iterator iter = itemsToRemove.iterator(); iter.hasNext();) {            currentBiomassItems.remove(iter.next());        }        currentLevel -= collectedMass;        //return the array        BioMatter[] emptyArray = new BioMatter[0];        BioMatter[] returnArray = (BioMatter[]) (itemsToReturn                .toArray(emptyArray));        if (returnArray == null)            return emptyArray;        else            return returnArray;    }