Variadic function: Difference between revisions

Content deleted Content added
m fix link
Variadic functions in C# and Java: not all versions of java
Line 43:
== Variadic functions in C# and Java ==
 
Other languages, such as [[C Sharp|C#]] and [[Java (programming language)|Java]] use a different approach - —they just allow that a variable number of arguments of the same (super)type may be passed to a variadic function. Inside the method they are simply collected in an [[array]].

This feature, called "varargs", has been present in Java since [[Java Platform, Standard Edition#Nomenclature, standards and specifications|J2SE 5.0]]. Using [[autoboxing]], this can also be used to pass [[Primitive type|primitive]] arguments to for example a print function, as can be seen in the Java example below:
 
public static void printSpaced(Object... objects) {