1

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?

user3239652
  • 775
  • 2
  • 9
  • 23

1 Answers1

1

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.

NeplatnyUdaj
  • 6,052
  • 6
  • 43
  • 76