I am writing a simple java class that makes use of the reflection API to find out the declared fields in the java.lang.class. Following is the piece of java code I have written.
Field[] fields = String.class.getDeclaredFields();
for (Field f : fields){
System.out.println("Field name: " + f.getName());
}
I am getting the following output when I run this program.
Field name: serialVersionUID
Field name: CASE_INSENSITIVE_ORDER
Field name: ascii
Field name: stringArray
Field name: stringArraySize
Field name: enableCopy
Field name: value
Field name: offset
Field name: count
Field name: hashCode
Field name: hashCode32
Field name: seed
Field name: startCombiningAbove
Field name: endCombiningAbove
Field name: upperValues
Field name: serialPersistentFields
When I looked at the source code of the String class, I found that there were only 6 fields defined for the class in API. I am not able to figure out where these additional fields are coming from in the output. Please help here.
Aucun commentaire:
Enregistrer un commentaire