我想在類中創建一個對象時使動態類中的方法名稱我想動態執行方法名稱下面是我的代碼。如何使類中的方法名稱動態化?
public static void ExecuteTest() throws Exception
{
for (int i = 1, j = 1; i < 2; i = i+1, j = j+1) {
FW_ReadExcelFile N = new FW_ReadExcelFile();
FW_ReadExcelFile.setExcelSheetEnvValues(i,i);
//java.lang.String Flag2 = N.getTCExecuteFlag() ;
String Flag = "YES";
String Flag21 = N.getTCExecuteFlag();
if (Flag.equals(Flag21) ){
String TCName = N.getTCName();
FW_Report u = new FW_Report();
u.TCName; // the FW_Report class has many methods and I want to call the method on my demand .
}
爲什麼你需要這樣做? – Teo
你的代碼風格表明你已經足夠新到Java,你*真*不應該嘗試反射。 – chrylis
我想要執行在本地excel表中有「是」的方法,而那些有「否」的方法應該被忽略。 –