Creating a method with a variable number of arguments

JDK1.5 allows methods to have a variable number of arguments. The syntax is to specify the type, three dots and the argument name. The variable number of arguments must be the last argument to the method. Other (normal) arguments may precede the variable argument list. Only one variable argument list may be specified.

Main.java:

public class Main
{
   public static void main(String []args) {
      printStrings("one arg");
      System.out.println("--------------");
      printStrings("an arg", "another arg");
   }
   
   public static void printStrings(String... strings) {
      for (int i=0; i<strings.length; i++) {
         System.out.println(strings[i]);
      }   
   }
}