in this code i want to put integers in a double list and then to check if the list is sorted or not so in a method i try to compare the value the first object of the list with the second, then the second with the third etc. what i dont remember/know is how you compare them
public class Ergasthrio6 {
public static boolean isSorted(DoubleLinkedList dl) throws ListEmptyException{
DoubleLinkedList selectedItem = (DoubleLinkedList) dl.removeFirst();
dl.insertLast(selectedItem);
DoubleLinkedList tmp;
for (int i=1; i < dl.size(); i++){
tmp = (DoubleLinkedList) dl.removeFirst();
dl.insertLast(tmp);
if (selectedItem < tmp)) <-----here
return false;
else
selectedItem = tmp;
tmp = tmp.removeFirst();
}
}
public static void main(String[] args) throws ListEmptyException {
// TODO code application logic here
DoubleLinkedList dl = new DoubleLinkedList();
for (int i=0; i < 10; i++)
dl.insertFirst(UserInput.getInteger());
isSorted(dl);
}
}