*
*/
package test;
/**
* @author Paolo
*
*/
public class VarArgsTest {
public static void method1VarArgs(int ...intsArray){
System.out.println("length =" + intsArray.length);
}
public static void method2VarArgs(String ...stringsArray){
System.out.println("length =" + stringsArray.length);
}
/**
* @param args
*/
public static void main(String[] args) {
method1VarArgs();
method1VarArgs(1,2,3);
method2VarArgs();
method2VarArgs("a", "b");
}
}
And output is :
length =0
length =3
length =0
length =2NOTES: Arrays are never null (neither if method is called without any parameter )
Nessun commento:
Posta un commento