public class MethodClass {
public String name(){
return "L$";
}
}
//调用MethodClass的name方法
public class TestCase2 extends TestCase {
public void testCase() {
MethodClass methodClass = new MethodClass();
try {
String name = methodClass.getClass().getMethod("name").invoke(methodClass.getClass().newInstance()).toString();
System.out.println(name);
System.out.println(methodClass.getClass().getSimpleName());
String str = String.format(Locale.CHINESE, "%s is %s", "牛人", "hero");
System.out.println(str);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException | InstantiationException e) {
e.printStackTrace();
}
}
}