Zer0megAlpha
Zer0megAlpha

Reputation: 33

How do you call a method with multiple arrays as input?

What I'm trying to do is call a method that takes two arrays as an input. It would look something like this.

pairs({2,3,4}, {1,0,2});

The problem I end up having is that it's an illegal start of an expression. I've tried using braces instead and have come up with the same problem.

pairs([2,3,4], [1,0,2]);

Is there a way to call a method using arrays like this or do I have to declare an array?

Upvotes: 1

Views: 210

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726849

You are pretty close: all you need to do is to add new operator, and provide the array type, like this:

pairs(new int[] {2,3,4}, new int[] {1,0,2});

Upvotes: 3

Related Questions