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
Post a Comment