Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Exemple de ‘varags’ surchargé


{filelink=4622}

public class SurchargeVarArgs {
 
   public static void main(String args[])
   {
 	testVarArgs(true, false, false);
     testVarArgs(1, 2, 3);
     testVarArgs("Test: ", 10, 20);
 
  }
  static void testVarArgs(int ... v) {
	  for(int x : v)
      System.out.print(x + " ");
 
    System.out.print("testVarArgs(int ...): " + "Nombre des arguments: " + v.length);
    System.out.println();
  }
 
  static void testVarArgs(boolean ... v) {
    System.out.print("testVarArgs(boolean ...) " +
                     "Nombre des arguments: " + v.length);
 
    for(boolean x : v)
      System.out.print(x + " ");
 
    System.out.println();
  }
 
  static void testVarArgs(String msg, int ... v) {
    System.out.print("testVarArgs(String, int ...): " + msg + v.length);
 
    for(int x : v)
      System.out.print(x + " ");
 
    System.out.println();
  }
 
}