Skip to main content

Posts

Showing posts with the label passing arguments

Passing Unspecified Number of Arguments To A Method

We didn't have feature that passing unspecified number of arguments to method, but this feature has been introduced with JDK 5.0. Java considers the variable-length argument list as an array. This is represented by argument type followed by three dots in the declaration of the Method. The following example can explain about this The method int sum(int…numbers) can take any number of parameters of type integer. public  int  sum ( int ...numbers ) {          int  sum= 0 ;          for  ( int  d : numbers  )                       sum =sum + d;          return  sum;      }      public static  void  main ( String []  args )...