I’m having two Java classes. The first implements the following method:
@Override public void onView(Object o) {
o = (Foo) o;
o.bar();
}
The second class Foo provides the bar method.
The problem now is that I get the “Cannot find symbol” compile error on the o.bar(); call.
What I’m doing wrong and how can I achive the call of the bar method?
Thanks
Your
ois a reference to anObject, notFoo. The cast works sinceFoois a subtype ofObject, like any other class, butoremains a reference to anObject.What you want is
((Foo) o).bar();