Java, generics mismatch -
im new java programming, used programmed in delphi/pascal know types.
a domain class:
public class domain extends baseobject {
the baseobject abstract class:
public abstract class baseobject {
there function has accept domain:
final class<baseobject> objecttype = new domain("1"); // here error something.load2(objecttype);
the load2 is
public <t extends baseobject> t load2 (class<t> objecttype, object... parameters) {
the problem line in comment:
type mismatch: cannot convert domain class
i thought load2()
may accept extends baseobject
, domain
too. or wrong?
you class of instance this:
domain d = new domain("1"); class<? extends domain> objecttype = d.getclass();
or, if know type @ compile-time (no need instance):
class<domain> objecttype = domain.class;
note, however, class<domain>
, not class<baseobject>
, , 2 types not assignment-compatible.
the best can (and looks want is)
class<? extends baseobject> objecttype = domain.class; // or class<? extends baseobject> objecttype = domain.getclass();
Comments
Post a Comment