Thursday, August 15, 2013

java 1.5 new jeatures VarArgs

VarArgs:

Variable is declare inside the method’s argument.It is

called as Varargs.

Syntax:

return type method_name( return type…. Value).

Example:

public class JdkVarArgs

        {

public static void main(String args[])

display();

display("hai","Welcome");

        }

        public static void display(String... values)//VarArg Method

        {

            System.out.println("Am Display method ");

         for(String s:values)

{

System.out.print(s);

}

        }


To learn more on  java training in chennai or java tutorial





Output:

Am Display method

Am Display method

Hai Welcome

No comments:

Post a Comment