rendered paste body while( done < 5 ){
System.out.println("Enter a name and score.");
sName = scanner.next();
dScore = scanner.nextDouble();
lis7.insertFirst(sName);
DLLis7.insertFirst(sName, dScore);
System.out.println("DLLis7.head = " + DLLis7.head);
done++;
System.out.println (" You entered \n name: "
+ lis7.toString()
+ " \n Score: ");
System.out.println (" You entered \n name: "
+ DLLis7.toString()
+ " \n Score: "
+ DLLis7.toString2()+'\n');
--------------------
not sure if this is right.....
final class LinkedListIterator{
LinkedListIterator (SinglyLinkedNodes theNode ) {
current = theNode;
}
public boolean isValid (){
return current != null;
}
public String retrieve (){
return isValid () ? current.getElement() : null;
}
public void advance( ) {
if (isValid() )
current = current.getNext();
}
SinglyLinkedNodes current;
}//iterator
protected SinglyLinkedNodes head;
protected long size;
public SinglyLinkedList(){
//header = new SinglyLinkedNodes("", null);
head = null;
size=0;
}
public void insertFirst(String s){
SinglyLinkedNodes newNode = new SinglyLinkedNodes(s, null);//1
newNode.setNext(head);//2
head=newNode;
size++;
}
public SinglyLinkedNodes getNext(){
return head;
}
public String toString( ) {
String s = "";
for( SinglyLinkedNodes n = head; n != null; n=n.getNext( ) ){
s += n.getElement( );
if( n.getNext( ) != null )
s += ", ";
}
return s;
}