Get all information about the class according to the class name

xiaoxiao2021-03-06  40

Java class Class provides all related information to get classes directly according to the class name, including the package, parent class, member, and method where the class is located, the following source code is the type and name of the class, you can view Class's documentation method for other information of the class, according to this, we can construct all information of Java core packages and other supplement packs without having to use the analysis document or source code, this is to construct a Java editor and want to provide input It is very convenient to help people, and below is a simple example of all public members of the output class Windows:

import java.lang.reflect *;. import java.awt *;. public class GetClassInfoFromClassname {public static void main (String args []) {Field [] fields = Window.class.getDeclaredFields (); System.out.println ( Window.class "HAVA" Fields.Length "Members:"); for (int i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-56911.html

New Post(0)