标签:javase 代码 window for 解析 ips cores on() gen
礼悟:
好好学习多思考,尊师重道存感恩。叶见寻根三返一,活水清源藏于零。
虚怀若谷良心主,皓月当空自在王。愿给最苦行无悔,诚劝且行且珍惜。
os :windows7 x64
jdk:jdk-8u131-windows-x64
ide:Eclipse Oxygen Release (4.7.0)
被解析类的代码:
package blog.jizuiku3;
/**
*
*
* @author jizuiku
* @version V17.10.02
*/
public class Person {
// 成员变量
public int age;
private String password;
protected String name;
int score;
public static int ageStatic=13;
private static String passwordStatic="hello world";
protected static String nameStatic;
static int scoreStatic;
// 构造方法
public Person(int age) {System.out.println("public GZ:int");}
public Person(int age,int score) {System.out.println("public GZ:int,int");}
private Person() {System.out.println("private GZ:");}
protected Person(String name) {System.out.println("protected GZ:String");}
Person(int age,String name){this.age=age;this.name=name;System.out.println("default GZ:int,String");}
// 成员方法
public void sayHello(String name) {}
private int sayHello() {return 1;}
protected String sayHello(int age) {return "";}
void sayHello(int age,String name) {}
public static void sayHelloStatic(String name) {}
private static int sayHelloStatic() {return 1;}
protected static String sayHelloStatic(int age) {return "";}
static void sayHelloStatic(int age,String name) {}
@Override
public String toString() {
return "Person [age=" + age + ", password=" + password + ", name=" + name + ", score=" + score + "]";
}
}
演示类:
package blog.jizuiku3;
import java.lang.reflect.Method;
/**
* Class getDeclaredMethods 获取自己的所有方法,不包括父类的
*
* @author jizuiku
* @version V17.10.03
*/
public class ClassGetAllFunDemo {
public static void main(String[] args) throws Exception {
String className = "blog.jizuiku3.Person";
Class c =Class.forName(className);
Method[] ms = c.getDeclaredMethods();
for (Method method : ms) {
System.out.println(method);
}
}
}
结果:

Java优秀,值得学习。
学习资源:itcast和itheima视频库。如果您有公开的资源,可以分享给我的话,用您的资源学习也可以。
博文是观看视频后,融入思考写成的。博文好,是老师讲得好。博文坏,是 给最苦 没认真。
JavaSE8基础 Class getDeclaredMethods 获取类的所有方法(不包括父类的)
标签:javase 代码 window for 解析 ips cores on() gen
原文地址:http://www.cnblogs.com/jizuiku/p/7637562.html