java - Usage of new Class<?>[]{} at getMethod -
is there difference between:
method getidmethod = myinterface.class.getmethod("getid");
and
method getidmethod = myinterface.class.getmethod("getid", new class<?>[]{});
myinterface follows:
public interface myinterface { anotherinterface getid(); }
no, there no difference. empty class[]
generated implicitly in first case.
the java language specification states
invocations of variable arity method may contain more actual argument expressions formal parameters. actual argument expressions not correspond formal parameters preceding variable arity parameter evaluated , results stored array passed method invocation (§15.12.4.2).
and invocation , evaluating arguments
if
m
being invokedk ≠ n
actual argument expressions, or, ifm
being invokedk = n
actual argument expressions , type of k'th argument expression not assignment compatiblet[]
, argument list(e1, ..., en-1, en, ..., ek)
is evaluated if written as(e1, ..., en-1, new |t[]| { en, ..., ek })
,|t[]|
denotes erasure (§4.6) oft[]
.
technically, equivalent to
new class[]{} // instead of new class<?>[]{}
Comments
Post a Comment