Method with Varargs in Java


Here is the simple program for printing basic example using Methods with Varargs in Java.

Source Code

//Method Overriding
import java.io.*;
import java.util.Scanner;
class funs
{
  funs(String...persons)
  {
    for(String name:persons)
    {
      System.out.println("Hello..."+name);
    }
  }
}
class vararg
{
  //www.tutorjoes.com
  public static void main(String args[])
  {
    funs o = new funs("Sam","Ram","ravi");
  }
}
To download raw file Click Here

Output

Hello...Tutor
Hello...Joes


Learn All in Tamil © Designed & Developed By Tutor Joes