
How to use Vargas method in java?

The given example illustrates the use of Vargas. Vargas represents variable length arguments in methods, it is having (Object?arguments) form In the given example, we have used this Vargas to print string variable. You can also pass parameters of other data types also.
public class Varags{
public static void main( String [] args){
Varags vr = new Varags();
vr.test(555.55f,444.4f, 0.6d, "Hello");
}
public void test( float i,float t, double d, String ... String)
{
for(String arg: String) {
System.out.print(" "+ arg);
System.out.print("\n");
System.out.println( " " + i);
System.out.println(" " + t);
System.out.println(" " + d);
}
}
}
Output
Hello 555.55 444.4 0.6
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.