1

Say I have a method such as:

public void printElements(int[] array)

How could I send an int[] as an argument without declaring it previously (so, actually create it inside the message). I want to avoid something like:

int[] anArray = { 5, 3, 10 };
Foo.printElements(anArray);

And use something (although this doesn't work) like this instead:

Foo.printElements( new int{ 5, 3, 10 } );
Luiggi Mendoza
  • 81,685
  • 14
  • 140
  • 306

0 Answers0