JAVA反射的问题,判断以下6个Class是type of a reference variable 还是 type of an objectClass c1 = x.getClass();Class c2 = x.getClass().getDeclaredFields()[0];\x05\x05Class c3 = x.getClass().getDeclaredFields()[0].get(x).getClass();\x05\x05C
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/30 08:13:12
![JAVA反射的问题,判断以下6个Class是type of a reference variable 还是 type of an objectClass c1 = x.getClass();Class c2 = x.getClass().getDeclaredFields()[0];\x05\x05Class c3 = x.getClass().getDeclaredFields()[0].get(x).getClass();\x05\x05C](/uploads/image/z/13479391-55-1.jpg?t=JAVA%E5%8F%8D%E5%B0%84%E7%9A%84%E9%97%AE%E9%A2%98%2C%E5%88%A4%E6%96%AD%E4%BB%A5%E4%B8%8B6%E4%B8%AAClass%E6%98%AFtype+of+a+reference+variable+%E8%BF%98%E6%98%AF+type+of+an+objectClass+c1+%3D+x.getClass%28%29%3BClass+c2+%3D+x.getClass%28%29.getDeclaredFields%28%29%5B0%5D%3B%5Cx05%5Cx05Class+c3+%3D+x.getClass%28%29.getDeclaredFields%28%29%5B0%5D.get%28x%29.getClass%28%29%3B%5Cx05%5Cx05C)
JAVA反射的问题,判断以下6个Class是type of a reference variable 还是 type of an objectClass c1 = x.getClass();Class c2 = x.getClass().getDeclaredFields()[0];\x05\x05Class c3 = x.getClass().getDeclaredFields()[0].get(x).getClass();\x05\x05C
JAVA反射的问题,判断以下6个Class是type of a reference variable 还是 type of an object
Class c1 = x.getClass();
Class c2 = x.getClass().getDeclaredFields()[0];
\x05\x05Class c3 = x.getClass().getDeclaredFields()[0].get(x).getClass();
\x05\x05Class c4 = x.getClass().getMethods()[0].getDeclaringClass();
\x05\x05Class c5 = x.getClass().getMethods()[0].getParameterTypes()[0];
\x05\x05Class c6 = x.getClass().getInterfaces()[0];
JAVA反射的问题,判断以下6个Class是type of a reference variable 还是 type of an objectClass c1 = x.getClass();Class c2 = x.getClass().getDeclaredFields()[0];\x05\x05Class c3 = x.getClass().getDeclaredFields()[0].get(x).getClass();\x05\x05C
Class
getDeclaringClass()
Returns the Class object representing the class or
interface that declares the method represented by this Method
object
Class
getReturnType()
Returns a Class object that represents the formal
return type of the method represented by this Method object.
Class[]
getInterfaces()
Determines the interfaces implemented by the class or interface
represented by this object.
Field[]
getDeclaredFields()
Returns an array of Field objects reflecting all the
fields declared by the class or interface represented by this Class
object.
java文档里写的很清楚 你看看上三个函数是你用到 它们的返回值都是Class 最后一个返回Field[] 对照你写的看看 除了c2是个变量外 其他的都是类对象