Issue
import java.awt.List;
import java.util.LinkedList;
import java.util.ListIterator;
public class HW1 {
public static void main(String[] args){
String s = "";
boolean flag = false;
int pos = -1;
List roster = new LinkedList(); <--
roster.add ( "alice" );
roster.add ( "bob" );
roster.add ( "chad" );
roster.add ( "dan" );
ListIterator<String> bookmark = roster.listIterator(); <--
try {
s = bookmark.next();
s = bookmark.next();
s = bookmark.next();
s = bookmark.next();
s = bookmark.next();
flag = bookmark.hasNext();
pos = bookmark.nextIndex();
}catch ( Exception trouble ) {
s = "Runtime Error generated";
}
}
}
This is considered a homework question, however I'm not looking for an answer. I'm getting multiple errors about resolving to a type, at the first error I get LinkedList and List cannot be resolved to a type. At the second arrow I get ListIterator cannot be resolved to a type.
I am very new to Eclipse and we haven't done any code writing yet for this class so I am not used to the format Can anyone tell me how to resolve the errors I am getting
Updated* Same errors as before except I now have 3 more. List and LinkedList are a type mismatch, LinkedList is a raw type and references to a generic type need to be parameterized. then the second arrow I now get listIterator() is undefined for the type
Solution
List roster = new LinkedList();
needs to become:
LinkedList roster = new LinkedList();
Answered By - Matt Clark
Answer Checked By - Cary Denson (JavaFixing Admin)