Java - Write code to define method with Varargs

Description

Write code to define method with Varargs

Demo

class Varargs {
  public static void main(String[] args) {
    hello(1,2,3,4,5);//from   w  ww. ja va2  s  . co  m
  }

  static void hello(int... values) {
    for(int i=0; i<values.length; i++)
      System.out.println(values[i]);
  }
}

Related Exercise