Hello JPF! I have just been introduced to LinkedList and I am working on my first programming assignment, but I am really confused and lost. My professor wants us to implement the program as a user; I am unsure what she means, so can anyone please explain this? Because I have just been introduced to LL, I am just playing around with it, and so far, I haven't been able to get anything to work.
I'm not writing any particular program at the moment, but I haven't been able to get the code below to print out right; I've been getting an error because there's something wrong with my insert method, but I do not know what. Can someone please tell me what I'm doing wrong?
import java.util.LinkedList; public class Editor { private LinkedList<String> text; public String display() { return text.getFirst() + "\n" + text.getLast(); } public void insert(String s) { text.add(s); } }
public class Tester { public static void main (String [] args) { Editor e = new Editor(); e.insert("test1"); e.insert("test2"); e.insert("test3"); System.out.println(e.display()); } }