hi, ya i changed it alot, but now it compiles but at runtime when the number is entered it just looks as if its waiting for more input except typing doesn't work and i have to close command prompt..i used arraylist and i ferget why i used bigdecimals... but ya here is the code:
public int[] getFactors(int number) { // number is the num to get the factors from
ArrayList fList = new ArrayList(2); // arraylist to use
int[] factors; // array to put the arraylist in
int j = 1; // counter no. 1 (sumwhere else in the program uses i)
Integer k; // counter no. 1 (object form so i can put it in the arraylist)
int l = 0; // counter no. 2
while ( j <= number ) { // while the factor test for true number is less or equal to the number
k = new Integer(j); // counter 1 object is same as int counter
if ( number % j == 0 ) { // if its a factor
fList.ensureCapacity(j); // make loads of room
if ( fList.contains(k) ) { // if it already has it
j++; // move on
}
else { // if not,
fList.add(k); // add the object(Integer) count(dont know why i cant put an int into it)
j++; // increase counter
}
}
else { // if it isn't a factor
j++; // move on
}
fList.trimToSize(); // trim the size of the list
}
factors = new int[fList.size()]; // factors = enough room for the list
while ( l < fList.size() ) { // while counter no.2 is less then size (not <= cause size starts 1 but index starts 0
factors[l] = Integer.parseInt(fList.get(l).toString()); // current factor array index is parsedint of the list object toString
}
return factors; // return the factors
} // end of getFactors method
the end part ( weird parseint of tostring of object of list thing) was built up cause i kept getting compiler errors.. when it was just current factor index = curent list index i got expected int got object compile error. when i changed all ints to integers and once all to objects i got errors.. when i had parseint it doesn't have a method to parseint objects, so i toString'ed them. i'm pretty confused with this, its all an annoying series of variable Type errors. If you can point me to the right direction, please do.