variadic-functions

Passing array elements to varargs

♀尐吖头ヾ 提交于 2020-08-22 07:00:57
问题 I have the following method on a superclass: public void method(Example... examples) { for (Example e : examples) { e.doSomething(); } } And this is the call on the subclass: super.method(examples[0], examples[1], examples[2], examples[3], examples[4], examples[5], examples[6], examples[7], examples[8], examples[9], examples[10]); Is there an easier way to pass the elements? Something like super.method(examples[0 -> 10]) ? I can't pass the entire array (super.method(examples)) to the method.

Passing array elements to varargs

安稳与你 提交于 2020-08-22 07:00:40
问题 I have the following method on a superclass: public void method(Example... examples) { for (Example e : examples) { e.doSomething(); } } And this is the call on the subclass: super.method(examples[0], examples[1], examples[2], examples[3], examples[4], examples[5], examples[6], examples[7], examples[8], examples[9], examples[10]); Is there an easier way to pass the elements? Something like super.method(examples[0 -> 10]) ? I can't pass the entire array (super.method(examples)) to the method.