I am very confused why the following code doesn't work. The observer object creates an observer with userName = jon.
The output for each line is:
but when I insert the following line:
I get an compilation error saying cannot resolve symbol userName. Whats going on here? I am v confused.
Jon
Code:
Observer observer = new Observer("jon");
Vector observersList = new Vector();
observersList.add(observer);
System.out.println(observer.userName);
System.out.println(observer.getClass());
System.out.println(observersList.elementAt(0).getClass());
System.out.println(observer.equals(observersList.elementAt(0)));
The output for each line is:
Code:
jon
Observer
Observer
true
but when I insert the following line:
Code:
System.out.println(observersList.elementAt(0).userName);
I get an compilation error saying cannot resolve symbol userName. Whats going on here? I am v confused.
Jon