What is the difference between String... args and String[] args in Java?
I am new to Java programming. Can someone tell me what the difference is between ( String....args ) and ( String [] args ) If I use the first instead of the second ........ Does it really matter?
String... args will declare a method that expects a variable number of String arguments. The number of arguments can be any: including zero.
String[] args , and the equivalent of String args[] will declare a method that expects exactly one argument: an array of strings.
One of the differences spring cannot make from these observations is that in the second case (but not in the first), the caller may have an array reference. In both cases, the method works with args as an array of strings, but if it does something like swap elements of the array, it will not be visible to the caller if the String... args form is used.
source share