class Employee {
double payAmt(String level){
double salary = 0;
switch (level) {
case "Level1":
salary = 100;
break;
case "Level2":
salary = 200;
break;
case "Level3":
salary = 300;
break;
}
return salary;
}
}
public abstract class Employee1 {
public abstract double payAmt();
}public class Level1 extends Employee1{
@Override
public double payAmt() {
return 100;
}
}@Test
public void test() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
String level = "Level2";
Employee1 employee1 = (Employee1) Class.forName("com.valtech.java."+level).newInstance();
System.out.println(employee1.payAmt());
}