package Fanshe; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.sql.Connection; import java.util.ArrayList; import utils.Conn; public class FConn { public static void main(String[] args) throws Exception { FConn.fConn1(Conn.class); } public static <T> ArrayList<T> fConn(Class<T> obj) throws Exception { Constructor<?> cons = obj.getDeclaredConstructor(); T newInstance = obj.newInstance(); Method method = obj.getMethod("link", new Class[] {}); method.invoke(newInstance, null); return null; } public static <T> ArrayList<T> fConn1(Class<T> obj) throws Exception { T newInstance = obj.newInstance(); Method m= obj.getDeclaredMethod("link"); m.invoke(newInstance); return null; } }