main - Is there any difference between String... args and String[] args in Java? -


this question has answer here:

what difference between string... args , string[] args in java?

i'm new java programming. can plz tell me what's difference between (string....args) & (string [] args) if i'll use first 1 in place of second........does make difference?

string... args declare method expects variable number of string arguments. number of arguments can @ all: including zero.

string[] args , equivalent string args[] declare method expects 1 argument: array of strings.

one difference might not spring out observations in second case (but not first) caller may have reference array. in both cases method works args array of strings, if things swap array elements not visible caller if string... args form used.

if have void x(string...args) method, can call x("1", "2", "3") while void x(string[] args) can called x(new string[] {"1", "2", "3"}).


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -