黑马程序员技术交流社区

标题: beanutils 报错找不到方法 [打印本页]

作者: oath    时间: 2013-8-7 15:23
标题: beanutils 报错找不到方法
本帖最后由 oath 于 2013-8-8 12:43 编辑
  1. import org.apache.commons.beanutils.BeanUtils;
  2. class Student{
  3.         private int age=20;
  4.         public int getAge() {
  5.                 return age;
  6.         }
  7.         public void setAge(int age) {
  8.                 this.age = age;
  9.         }        
  10. }
  11. class Introspection_BeanUtils {

  12.         public static void main(String[] args) throws Exception{
  13.                 Student p=new Student();
  14.                 BeanUtils.getArrayProperty(p,"age");        
  15.         }
  16. }
复制代码

Student类中明明有set get方法  ,哪里出错了 ?

作者: sergio    时间: 2013-8-7 18:50
{:soso_e101:}不知道什么原因。google下student类要用public来修饰,单独写一下。
作者: oath    时间: 2013-8-7 20:54
sergio 发表于 2013-8-7 18:50
不知道什么原因。google下student类要用public来修饰,单独写一下。

nice

  感谢




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