A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 蒋淑静 中级黑马   /  2014-1-6 23:13  /  1347 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

这样使用BeanUtils工具包获取属性的值对不?
  1. public class ReflectPoint {
  2.         private int x;
  3.         public int y;
  4.        
  5.         ReflectPoint(int x,int y){
  6.                 this.x=x;
  7.                 this.y=y;
  8.         }
  9.         public int getX() {
  10.                 return x;
  11.         }
  12.         public void setX(int x) {
  13.                 this.x = x;
  14.         }

  15. }
复制代码

  1. import org.apache.commons.beanutils.BeanUtils;
  2. public class JavaBeanTest {
  3.         public static void main(String[] args) throws Exception{
  4.                 ReflectPoint pt1 = new ReflectPoint(3,5);
  5.                 System.out.println(BeanUtils.getProperty(pt1,"x"));
  6.         }
  7. }
复制代码

评分

参与人数 1技术分 +1 收起 理由
FFF + 1 这个问题可能比较深入~我也不知道呢~.

查看全部评分

4 个回复

倒序浏览
没有人能帮忙看一下吗?
回复 使用道具 举报
        这个问题可能比较深入~我也不知道呢~只要结果对就好啦、
回复 使用道具 举报
我就是试了好像不能用,也不知道正确的使用方式是什么?,我再查查资料看吧,谢谢你
回复 使用道具 举报
FFF 发表于 2014-1-8 08:28
这个问题可能比较深入~我也不知道呢~只要结果对就好啦、


我就是试了好像不能用,也不知道正确的使用方式是什么?,我再查查资料看吧,谢谢你
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马