Java - What is wrong: varargs method parameter?

Question

What is the wrong of the following code?

void m1(String str, int...n1, int...n2) {
  // Code goes here
}


Click to view the answer

it declares two variable-length arguments

Note

m1() method is invalid because it declares two variable-length arguments, n1 and n2.

How to fix


class Account {
  void m1(String str, int...n1) {
    // Code goes here
  }
}

Related Quiz