Hi,
Im having a pla with the LinkedList facility, and am just looing to be able to do one thing. Is it possible to go through your LinkedList and output all of the values within the list?
Ive had a go with the following and its printing the first, third and final value, but not he ones inbetween?
Im having a pla with the LinkedList facility, and am just looing to be able to do one thing. Is it possible to go through your LinkedList and output all of the values within the list?
Ive had a go with the following and its printing the first, third and final value, but not he ones inbetween?
Code:
import java.util.LinkedList;
class stack
{
public static void main(String args[])
{
LinkedList stack = new LinkedList();
stack.addFirst("Homer");
stack.addFirst("Marge");
stack.addFirst("Bart");
stack.addFirst("Lisa");
stack.addFirst("Maggie");
System.out.println("In order as entered:");
for(int n=0; stack.size()>n ; n++)
{
System.out.println("Stack Value:" + stack.size() + "\t\tValue: "+ stack.remove(n));
}
}
}