Unexpected type error within inner for loop
I keep getting anunexpected type error trying to state the position of the
index for the list (of type LinkedList), within the inner for loop (see code below).
Rather than hardcoding in the index, I used a variable. What I cannot understand though is
why this error only applies to that particular line, when the same thing (code) is
duplicated in other lines?
import java.util.Comparator;
import java.util.LinkedList;
publicclass ShellSortLinkedList
{
private Comparator delegate;
private LinkedList list;
publicstatic LinkedList sort(LinkedList list,
Comparator delegate)
{
ShellSortLinkedList ssll =new ShellSortLinkedList();
ssll.list = list;
int sepDist = 1;// separation distance
while(sepDist < list.size())
{
sepDist = 3 * sepDist + 1;
}
while(sepDist > 0)
{
sepDist = (sepDist -1)/3;
for (int index = sepDist;
index < list.size(); ++index )
{
Object item = list.get(index);
int j = 0;
for(j = index - sepDist;
j >= 0 && delegate.compare(item, list.get(index)) < 0;
j -= sepDist)
{
int value = j+sepDist;
list.get(value) = list.get(j);
}
}// outer for loop
}// while loop
return list;
}// sort(LinkedList, Comparator)
Many thanks!
Reformer...
PS I did a search before pasting this message, but it did not generate any useful
information.

