I'm trying to add string objects to a linked list but i keep getting an error when I try to return the list
import java.util.LinkedList;
import java.util.ListIterator;
public class StacksAndQueues {
LinkedList<String> list = new LinkedList<String>();
private String[] words = {"goats", "cheese"};
public StacksAndQueues() {}
public String Add() {
/**
This method is used to load an array of string objects
into a linked list
*/
int x;
for (x=0; x < words.length; x++) {
list.add(x, words[x]);
}
return list;
}
}