Source Code : Old style: Use an array to pass a variable number of arguments
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Old style: Use an array to pass a variable number of arguments

public class PassArray {
static void vaTest(int v[]) {
System.out.print("Number of args: " + v.length + " Contents: ");
for (int x : v)
System.out.print(x + " ");
System.out.println();
}
public static void main(String args[]) {
int n1[] = { 10 };
int n2[] = { 1, 2, 3 };
int n3[] = {};
vaTest(n1); // 1 arg
vaTest(n2); // 3 args
vaTest(n3); // no args
}
}
Thank with us