提交 8f026e83 编写于 作者: 门心叼龙's avatar 门心叼龙

add function

上级 427425dc
package temp;
/**
* Description: <T1><br>
* Author: mxdl<br>
* Date: 2019/8/12<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public class T1 implements Runnable{
private int age;
public T1(){
this.age = 88;
}
public String getAge(String name,int age) {
return name+age;
}
public void setAge(int age) {
this.age = age;
}
static int a;
static void test(){
System.out.println("t1");
int i = Integer.parseInt("1123");
String s = Integer.toString(12);
};
@Override
public void run() {
}
}
package temp;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Description: <T2><br>
* Author: mxdl<br>
* Date: 2019/8/12<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public class T2 {
public static void main(String[] args){
Class<T1> t1Class = T1.class;
try {
Constructor<T1> constructor = t1Class.getConstructor();
T1 o = constructor.newInstance();
Method ageMethord = t1Class.getMethod("getAge",String.class,float.class);
String res = (String) ageMethord.invoke(o,"gxl",11112);
System.out.println("age2:"+res);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
static void test(){
System.out.println("t2");
};
}
package temp;
/**
* Description: <T3><br>
* Author: mxdl<br>
* Date: 2019/8/12<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public class T3 {
}
package temp;
/**
* Description: <T4><br>
* Author: mxdl<br>
* Date: 2019/8/12<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public class T4 extends T1{
class T5 extends T1{
}
class T6 extends T2{
}
class T7 extends T3{
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册