The java.lang.Class.getFields() returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object.The 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.
Syntax:public Field[] getFields() throws SecurityException
Example:import java.lang.reflect.*;
public class ClassDemo {
public static void main(String[] args) {
try {
Class cls = Class.forName("java.awt.Label");
System.out.println("Fields =");
// returns the array of Field objects representing the public fields
Field f[] = cls.getFields();
for (int i = 0; i < f.length; i++) {
system.out.println(f[i]);
}
}
catch (exception e) {
system.out.println("exception: " + e);
}
}
}
License.
All information of this service is derived from the free sources and is provided solely in the form of quotations.
This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 102 / 159177921. Delta: 0.00329 с