Lister les arguments d’une méthode

Author:


public class ExempleVarArgs {
static void testVa(int… v) {
System.out.print(“Nombre des arguments: ” + v.length);
{filelink=4620}

public class ExempleVarArgs {
  static void testVa(int... v) {
    System.out.print("Nombre des arguments: " + v.length);

    for (int x : v)
      System.out.print(x + " ");

    System.out.println();
  }

  public static void main(String args[]) {
    testVa(10); // 1 arg
    testVa(1, 2, 3); // 3 args
    testVa(); // pas d'args
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *