I'm a class that keeps track of stuffs and their owners
public class Record { //S - generic stuff, O - generic owner
HashSet allStuffs;
HashMap whoOwnsWhat;
//
}
How can I enforce that S must be subclass of certain class/interface.
Thank you.
EDIT:
I modified Record to be "class Record" where Stuff is an abstract class, and got a warning "the type parameter Stuff is hiding the type Stuff".
public class Records also get a complier complaint.
解决方案
There are extends and super keywords to define bounds for Java generics.
public class Record {
HashSet allStuffs(fooClassName arg); // do not "override" S by putting S HashSet allStuffs;
HashMap whoOwnsWhat (fooClassName arg1, O arg2);
}