0

I am working on a design, where I am using var argument. Now the problem is I need to use two different type of var arguments.

method signature

void addInformation(
    final String call,
    final ApiEnum... apis,
    final ApiTypes... types);

As this is not possible. What could be a better alternative to this design.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
mitali
  • 87
  • 8
  • Alternatively, a builder pattern-esque approach would allow for as many varargs as you want. – Rogue Dec 03 '21 at 06:33

1 Answers1

0

this may help:

class ApiModel {
    ApiEnum api;
    ApiTypes type;
}
void addInformation(String call, ApiModel... args)

but, varargs is a compromise.

shanfeng
  • 503
  • 2
  • 14