publicclass java.util.Date
{
public java.util.Date(java.lang.String);
public java.util.Date(int, int, int, int, int, int);
public java.util.Date(int, int, int, int, int);
public java.util.Date();
public java.util.Date(long);
public java.util.Date(int, int, int);
public boolean equals(java.lang.Object);
public java.lang.String toString();
public int hashCode();
public java.lang.Object clone();
public volatile int compareTo(java.lang.Object);
public int compareTo(java.util.Date);
public static java.util.Date from(java.time.Instant);
private void readObject(java.io.ObjectInputStream);
private void writeObject(java.io.ObjectOutputStream);
private final sun.util.calendar.BaseCalendar$Date normalize(sun.util.calendar.BaseCalendar$Date);
private final sun.util.calendar.BaseCalendar$Date normalize();
public boolean before(java.util.Date);
public boolean after(java.util.Date);
public static long parse(java.lang.String);
public int getSeconds();
public java.time.Instant toInstant();
public static long UTC(int, int, int, int, int, int);
public int getYear();
public long getTime();
public void setTime(long);
static final long getMillisOf(java.util.Date);
public void setDate(int);
public int getMonth();
private final sun.util.calendar.BaseCalendar$Date getCalendarDate();
public void setHours(int);
public int getHours();
public int getMinutes();
public void setMonth(int);
public void setMinutes(int);
public void setSeconds(int);
public void setYear(int);
private static final sun.util.calendar.BaseCalendar getCalendarSystem(long);
private static final sun.util.calendar.BaseCalendar getCalendarSystem(int);
private static final sun.util.calendar.BaseCalendar getCalendarSystem(sun.util.calendar.BaseCalendar$Date);
private final long getTimeImpl();
private static final java.lang.StringBuilder convertToAbbr(java.lang.StringBuilder, java.lang.String);
private static final synchronized sun.util.calendar.BaseCalendar getJulianCalendar();
public int getDate();
public int getDay();
public java.lang.String toLocaleString();
public java.lang.String toGMTString();
public int getTimezoneOffset();
public java.util.Date(java.lang.String);
public java.util.Date(int, int, int, int, int, int);
public java.util.Date(int, int, int, int, int);
public java.util.Date();
public java.util.Date(long);
public java.util.Date(int, int, int);
}
Process finished with exit code 0
代码
packagereflection;importjava.util.*;importjava.lang.reflect.*;publicclassReflectionTest {publicstaticvoidmain(String[] args) {// read class name from command line args or user inputString name;if(args.length>0) name = args[0];else {Scanner in =newScanner(System.in);System.out.println("输入一个类的名称 (例如 java.util.Date): "); name =in.next(); }try {// Print class name and superclass name (if != Object)Class cl =Class.forName(name);Class supercl =cl.getSuperclass();String modifiers =Modifier.toString(cl.getModifiers());if(modifiers.length() >0) System.out.print(modifiers +"");System.out.print("class "+ name);if(supercl !=null&& supercl !=Object.class) System.out.printf(" extends "+supercl.getName());System.out.printf("\n{\n");printConstructors(cl);System.out.println();printMethods(cl);System.out.println();printFields(cl);System.out.println("}"); }catch (ClassNotFoundException e) {e.printStackTrace(); }System.exit(0); } /** * Prints all constructors of a class * @param cl a class */privatestaticvoidprintFields(Class cl) {Constructor[] constructors =cl.getDeclaredConstructors();for (Constructor c : constructors) {String name =c.getName();System.out.printf(" ");String modifiers =Modifier.toString(c.getModifiers());if(modifiers.length() >0) System.out.printf(modifiers +" ");System.out.printf(name +"(");// print parameter typesClass[] paramTypes =c.getParameterTypes();for (int j =0; j <paramTypes.length; j++) {if(j >0) System.out.printf(", ");System.out.printf(paramTypes[j].getName()); }System.out.println(");"); } } /** * Prints all methods of a class * @param cl a class */publicstaticvoidprintMethods(Class cl) {Method[] methods =cl.getDeclaredMethods();for (Method m : methods) {Class retType =m.getReturnType();String name =m.getName();System.out.print(" ");// print modifiers, return type and method nameString modifiers =Modifier.toString(m.getModifiers());if (modifiers.length() >0) System.out.print(modifiers +" ");System.out.print(retType.getName() +" "+ name +"(");// print parameter typesClass[] paramTypes =m.getParameterTypes();for (int j =0; j <paramTypes.length; j++) {if (j >0) System.out.print(", ");System.out.print(paramTypes[j].getName()); }System.out.println(");"); } } /** * Prints all constructors of a class * @param cl a class */publicstaticvoidprintConstructors(Class cl) {Constructor[] constructors =cl.getDeclaredConstructors();for (Constructor c : constructors) {String name =c.getName();System.out.print(" ");String modifiers =Modifier.toString(c.getModifiers());if (modifiers.length() >0) System.out.print(modifiers +" ");System.out.print(name +"(");// print parameter typesClass[] paramTypes =c.getParameterTypes();for (int j =0; j <paramTypes.length; j++) {if (j >0) System.out.print(", ");System.out.print(paramTypes[j].getName()); }System.out.println(");"); } }}
Class
Description
AccessibleObject
The AccessibleObject class is the base class for Field, Method, and Constructor objects (known as reflected objects).
Array
The Array class provides static methods to dynamically create and access Java arrays.
Constructor\
Constructor provides information about, and access to, a single constructor for a class.
Executable
A shared superclass for the common functionality of Method and Constructor.
Field
A Field provides information about, and dynamic access to, a single field of a class or an interface.
Method
A Method provides information about, and access to, a single method on a class or interface.
Modifier
The Modifier class provides static methods and constants to decode class and member access modifiers.
Parameter
Information about method parameters.
Proxy
Proxy provides static methods for creating objects that act like instances of interfaces but allow for customized method invocation.