Variadic function: Difference between revisions

Content added Content deleted
(Fix missing code line in the second Lang example)
Line 1,031: Line 1,031:


<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
module VariadicFunction
module VariadicFunction {
void show(String[] strings) {
{
void show(String[] strings)
{
@Inject Console console;
@Inject Console console;
strings.forEach(s -> console.print(s));
strings.forEach(s -> console.print(s));
}
}


void run()
void run() {
{
show(["hello", "world"]);
show(["hello", "world"]);


Line 1,048: Line 1,045:
String s4 = "literal";
String s4 = "literal";
show([s1, s2, s3, s4]);
show([s1, s2, s3, s4]);
}
}
}
}
</syntaxhighlight>
</syntaxhighlight>