This sample demonstrate how to pass unlimited arguments to your function and how to know object types passed to your function.
public class UnlimitedArgs { /** Default constructor */ public UnlimitedArgs() { } public static void main(String args[]) { UnlimitedArgs g = new UnlimitedArgs(); g.viewObjArgs("Mega_unknown@hotmail.com",1.100,1111,1.2,411,552555.66); } /** * Unlimited Argument List like printf in C++,Java .Holds int Type. * unlimited int values */ private void viewIntArgs(int ... Numbers){ for(int i : Numbers) { System.out.println(i); } System.out.println("Lenght of my argument list is : " + Numbers.length); } //What if we dont know object type. So we will set data type as Object /** *Unlimited Argument List like printf in C++,Java .Holds Object Type. */ private void viewObjArgs(Object ... objects) { for(Object obj:objects) { //return type name System.out.println(obj.getClass()); } System.out.println("Lenght of my argument list is : " + objects.length); } }