+ 1

Passing an array as an argument

Let's say that I need to pass an array in Java as an argument is it necessary for me to create objects for it or can I use the primitive methods to do the same?

14th Feb 2017, 6:37 PM
Arpan Sircar
Arpan Sircar - avatar
2 ответов
+ 5
You have to create an object, can't think of another way. But you can create it anonymous when you call the method, like: method(new String[] {"john", "james"});
14th Feb 2017, 6:46 PM
Tashi N
Tashi N - avatar
+ 1
in java you can pass the array with refrence
14th Feb 2017, 7:57 PM
salman rahmani
salman rahmani - avatar