Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Combinaison ‘varargs’ et les arguments standards


{filelink=4621}

public class CombinaisonVarArgs {
 
  public static void main(String args[]) {
    testVarArgs("deux vararg: ", 10, 14);
    testVarArgs("Trois varargs: ", 1, 2, 3);
    testVarArgs("Pas de varargs: ");
  }
  static void testVarArgs(String msg, int... v) {
    for (int x : v)
      System.out.print(x + " ");
 
     System.out.print(msg + v.length);
     System.out.println();
  }
 
}