java反射总结

         * 构造方法,属性,一般方法的对象都是一样获取的
         * getConstructor(参数);   getDeclaredConstructor(参数);   getContructors();   getDeclaredConstructors();
         * getField(参数);            getDeclaredField(参数);     getFields();          getDeclaredFields();
         * getMethod(参数);       getDeclaredMethod(参数);        getMethods();             getDeclaredMethods();
         *
         *构造方法对象获取的目地是创建对象  使用newInstance(参数);方法就可以创建对象了
         *属性对象获取的目地是属性赋值,使用set(对象,值)
         *方法对象的获取是为了执行方法,使用invoke(对象,参数);
         *
         * 此外,当如果构造方法,属性,方法的修饰符为private修饰的时候,这时候就需要使用setAccessible(true)来暴力访问
        

猜你喜欢

转载自blog.csdn.net/wumanxin2018/article/details/78292936