I have this generic class:
final class Box<T> {
public T t;
public void add(T t) {
this.t = t;
}
public T get() {
return t;
}
}
Given that there is another class Group
, I am trying the following:
Box group1=new Box<Group>();
Group group = methodThatReturnsAGroupObject();
group1.add(group);
System.out.println(group1.get().getMembers().getValue());
Trying to compile this throws a "cannot find symbol" error for getMembers()
. If I replace group1.get()
simply with group
, it compiles without issue. What am I doing wrong?
EDIT: So it was explained that my first line should have been:
Box<Group> group1=new Box<Group>();
But after updating to that, I am still getting the compiler error about "cannot find sybol". So as it is no longer a raw type, what other mistake am I making?