package com.xp.reflect;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class ObjectClass {
public static void main(String[] args) {
Class<?> objectType=Object.class;
Method[] methods=objectType.getMethods();
Constructor<?>[] objectGet=objectType.getConstructors();
for(int i=0;i<methods.length;i++){
System.out.println(methods[i]);
}
System.out.println("---------------------------------------------------");
for(int i=0;i<objectGet.length;i++){
System.out.println(objectGet[i]);
}
}
}
/*Class<?> objectType=Object.class;
Method[] methods=objectType.getMethods();
Constructor<?>[] objectGet=objectType.getConstructors();
for(int i=0;i<methods.length;i++){
System.out.println(methods[i]);
}
System.out.println("---------------------------------------------------");
for(int i=0;i<objectGet.length;i++){
System.out.println(objectGet[i]);
}
* 上面这一段代码 如果将反射的部分放到mian()方法外面是不合法的
* 为什么呢?
*/
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class ObjectClass {
public static void main(String[] args) {
Class<?> objectType=Object.class;
Method[] methods=objectType.getMethods();
Constructor<?>[] objectGet=objectType.getConstructors();
for(int i=0;i<methods.length;i++){
System.out.println(methods[i]);
}
System.out.println("---------------------------------------------------");
for(int i=0;i<objectGet.length;i++){
System.out.println(objectGet[i]);
}
}
}
/*Class<?> objectType=Object.class;
Method[] methods=objectType.getMethods();
Constructor<?>[] objectGet=objectType.getConstructors();
for(int i=0;i<methods.length;i++){
System.out.println(methods[i]);
}
System.out.println("---------------------------------------------------");
for(int i=0;i<objectGet.length;i++){
System.out.println(objectGet[i]);
}
* 上面这一段代码 如果将反射的部分放到mian()方法外面是不合法的
* 为什么呢?
*/
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货