In java, is it possible to use a variable in the method name when calling the method? For example, see the following psudeocode:
for (i = 0 through 5)
{
methodi();
}
where the methods are
method1()
{
}
method2()
{
}
.
.
.
method5()
{
}
In java, is it possible to use a variable in the method name when calling the method? For example, see the following psudeocode:
for (i = 0 through 5)
{
methodi();
}
where the methods are
method1()
{
}
method2()
{
}
.
.
.
method5()
{
}
Why not make a single method with a switch
inside?
void method(int val)
{
switch(val){
case 1:
// method 1
break;
case 2:
// method 2
break;
case 3:
// method 3
break;
default:
System.out.println("No such method!");
}
}