flexible_vargas1
 
Create a method move, and overload as shown in the screen shots

a) with integer parameter

b) with double parameter

c) with string parameters

Calling varags method from entry point

Complete : Code:

/**
*
*/
import java.io.*;
import javax.swing.JOptionPane;
import java.net.URI;
/**
* @author Manas9
*
*/
public class ClassTemplate1 {
/**
*
*/
public ClassTemplate1() {
// TODO Auto-generated constructor stub

}
public static void main(String[] args)
throws Exception {
// TODO Auto-generated method stub
myClass mls = new myClass();
try {
//
mls.move(2,4,7,8);
mls.move(2.5,4.5,7.25,8.25);
mls.move("A","B","C","D");
//
} catch (NumberFormatException exc) {
//
}
}

}// end of class template

class myClass {

protected void move(int... dx)
{
System.out.println("print inegers varags ;" + dx);
System.out.print("you entered ");
for(int i: dx){
System.out.print(i +",");
}
System.out.println();
}
protected void move(double...str)
{
System.out.println("print double varags ;" +str);
System.out.print("you entered ");
for(double i: str){
System.out.print(i +",");
}
System.out.println();
}
protected void move(String... dx)
{
System.out.println("print string varags ;" +dx);
System.out.print("you entered ");
for(String i: dx){
System.out.print(i +",");
}
System.out.println();
}
}
 

Runtime output: