I'm picking up Java for a class, and having prior C++ knowledge this stuff has been fairly straightforward with the exception of trying to learn the whole IO system in this language. But there seems to one error I just cannot figure out what it's trying to tell me,
className.java:line_number: error: cannot find symbol myList.add(input); ^
I have dealing with this error left and right after picking up this language, and I can never seem to figure out what it's trying to tell me. I've heard people say it's referring misspelled objects or methods, but I've double and triple checked my code and that never seems to be true for me.
I'm trying to make a small program which will allow me to play with the LinkedList object so I can gain some familiarity with how they work in Java, and I have this code so far:
import java.io.*; import java.util.*; public class playWithLists { public static void main(String[] args) throws Exception { //List<String> myList = new LinkedList<String>(); LinkedList myList = new LinkedList(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String input = ""; for (int i = 0; i < 5; i++) { try { input = br.readLine(); } catch (Exception e) { System.err.println("Uh oh!"); } myList.add(input); } for (int i = 0; i < 5; i++) { System.out.println(myList.removeFirst()); } } }
The compiler is giving me an error at line 16 (specifically: myList.add(input); )
Can anyone give me some advice on what I'm missing here? This error is driving me nuts.