Hello everybody,
I have been working on this code segment for about three days and cannot figure out what is causing this error. I am trying to get a specific value out of an arraylist of sorted objects.
Here is the code:
public RateEstimator getMinRate()
{
// return null if array list empty
// first sort the collection via a method call
// now return the first element in list
// declare a RateEstimator called tmp
RateEstimator tmp;
// check for empty array
if (rates.size() == 0) return null;
{
// sort by method call
sortByRate();
//assign the value in rates position 0 to temp
tmp = rates.get(0);
// assign the value of the getRateMethod of temp to
// a double called smallest
double smallest = tmp.getTermRate();
//return the value in smallest
return smallest;
}
}
When I try to compile this I get the error : Incompatible types - found double but expected RateEstimator.
RateEstimator is the name of the arrayList I'm working with.
This is in fact part of a homework problem, but I have been through every Java book I own and cannot nail this down. I'm sure I'm missing something simple as I think my basic approch is correct. Any advice would be greatly apriciated.
Thanks
-Paul