gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 03:55:49 25 4
gpt4 key购买 nike

例如: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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com