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 invoked k ≠ n actual argument expressions, or, if m being invoked k = n actual argument expressions , type of k'th argument expression not assignment compatible t[], argument list (e1, ..., en-1, en, ..., ek) is evaluated if written as (e1, ..., en-1, new |t[]| { en, ..., ek }), |t[]| denotes erasure (§4.6) of t[].

technically, equivalent to

new class[]{} // instead of new class<?>[]{} 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -