java - "getDeclaredXyz"在Java反射包中代表什么

标签 java reflection

例如:o.getClass().getDeclaredFields()o.getClass().getFields()

“声明的”是在当前源文件中声明的吗?

最佳答案

getDeclaredFields() :

Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object. This includes public, protected, default (package) access, and private fields, but excludes inherited fields. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no fields, or if this Class object represents a primitive type, an array class, or void.

getFields() :

Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface has no accessible public fields, or if it represents an array class, a primitive type, or void. Specifically, if this Class object represents a class, this method returns the public fields of this class and of all its superclasses. If this Class object represents an interface, this method returns the fields of this interface and of all its superinterfaces.

关于java - "getDeclaredXyz"在Java反射包中代表什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6460980/

相关文章:

r - 如何获取在 R 中重新创建数据框的代码?

java - JPanel 内自由绘图

java - Hazelcast对称加密用java检查

java - Java中如何创建跨进程的Singleton类

未设置 -Djava.ext.dirs 时未从目录加载 Java SPI JAR

java - 使用数组参数的参数化 JUnit 测试中的反射异常

java - 变量args反射方法调用

java - LSOF 命令不显示 java 和类文件

c# - 如何在Unity.Mvc IoC容器中注册从基类继承的所有类?

c# - ASP.NET MVC 使用数据注释迭代模型属性