importjava.util.ArrayList;publicclassFactorsextendsArrayList<Integer>{publicFactors(int[]nums){___________________________________________for(inti:nums){______________________________________}___________________________________________}/* Precondition: this object contains a list of factors computed from some number.
All but the last is guaranteed to be a prime number, and the factors are in non-decreasing
order (they stay the same, or go up, from lowest index to highest index.)
Postcondition: If the last element is a prime number,
return the same ArrayList, unchanged.
Otherwise, take the last element, factor out the lowest prime factor, and replace
the last element with two elements; the prime factor, and the product of the remaining
factors.
*/publicvoidaddNextFactor(){intlastElement=____________________________________// in special case where last element is 4, need <= lastElement/2 not < 2for(inti=2;i<=lastElement/2;i++){if(lastElement%i==0){this.replaceLastFactor(i);this.addFactor(lastElement/i);return;}}}// NOTE: This method is complete and correct.// You don't need it except to understand the context of the other codepublicstaticFactorsprimeFactors(intnum){Factorsf=newFactors(newint[]{num});intprevSize=0;while(f.size()!=prevSize){prevSize=f.size();f.addNextFactor();}returnf;}/** replace last factor with the value i */publicvoidreplaceLastFactor(inti){_________________________________}/** add factor to end of list */publicvoidaddFactor(intf){_____________________________}}