Was going through a question on so,and this thing confused me
getDeclaredConstructor(new Class[]{String.class,Integer.class})
but this thing also works
getDeclaredConstructor(String.class,Integer.class)
then why we use the above one?
Was going through a question on so,and this thing confused me
getDeclaredConstructor(new Class[]{String.class,Integer.class})
but this thing also works
getDeclaredConstructor(String.class,Integer.class)
then why we use the above one?
You can use both and the behavior is the same. I guess it's just for convenience.
http://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html
The three periods after the final parameter's type indicate that the final argument may be passed as an array or as a sequence of arguments. Varargs can be used only in the final argument position.