黑马程序员技术交流社区

标题: 内省反射出来的class java.lang.Class是什么? [打印本页]

作者: 75100313    时间: 2014-3-24 14:56
标题: 内省反射出来的class java.lang.Class是什么?
本帖最后由 75100313 于 2014-3-24 14:58 编辑

Person类:
  1. package com.mth.bean;

  2. import java.util.Date;

  3. public class Person {
  4. private String name;
  5. private int age;
  6. private Date birthday;

  7. public Person() {
  8. super();
  9. // TODO Auto-generated constructor stub
  10. }

  11. public Person(String name, int age, Date birthday) {
  12. super();
  13. this.name = name;
  14. this.age = age;
  15. this.birthday = birthday;
  16. }

  17. public int getAge() {
  18. return age;
  19. }

  20. public void setAge(int age) {
  21. this.age = age;
  22. }

  23. public Date getBirthday() {
  24. return birthday;
  25. }

  26. public void setBirthday(Date birthday) {
  27. this.birthday = birthday;
  28. }

  29. public String getName() {
  30. return name;
  31. }

  32. public void setName(String name) {
  33. this.name = name;
  34. }

  35. @Override
  36. public String toString() {
  37. return "Person [age=" + age + ", birthday=" + birthday + ", name="
  38. + name + "]";
  39. }
  40. }
复制代码

内省:






作者: 菠萝鱼    时间: 2014-3-24 16:49
应该是 把 getBeanInfo(Person.class)中的参数(Person.class)当成一个属性列出来了。
作者: 75100313    时间: 2014-3-24 20:45
菠萝鱼 发表于 2014-3-24 16:49
应该是 把 getBeanInfo(Person.class)中的参数(Person.class)当成一个属性列出来了。 ...

汗  不明白 为什么会把这个拿出来  不是只能反射出来person的字段?




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2