I currently have the following method in a class which I hope I can push to a superclass since I will have a few other classes which will need similar functionality.
public long convertToLong(EnumSet<SomeTypeHere> es) {
long a = 0;
for(SomeTypeHere sth : es) {
a += sth.someLongProperty();
}
}
It would be great if I can do this, I’ve never really used java generics before other than with collections.
You will need to put a bound on the generic type. If the class which contains
convertToLongis parameterized on the same type, you can put the bound there:Or if the class which contains
convertToLongis not generic, you can put the bound in the declaration of that one method alone: