- <p>public class IntroSpectorDemo {
- public static void main(String[] args) throws Exception {
- ReflectPoint pt1 = new ReflectPoint(3, 5);
-
- pt1.setX(8);
- System.out.println(pt1.getX());
- //这里上下两中代码效果都一样,那到底用javabean的方式有什么好处啊
- //在这里看上去都要繁琐的多
- BeanUtils.setProperty(pt1, "y", "9");
- System.out.println(BeanUtils.getProperty(pt1, "y"));
- }
- }
- class ReflectPoint
- {
- private int x;
- public int y;
- public int getX() {
- return x;
- }
- public void setX(int x) {
- this.x = x;
- }
- public int getY() {
- return y;
- }
- public void setY(int y) {
- this.y = y;
- }
- }</p>
复制代码 javabean到底有什么好处啊,看上去比普通方式更繁琐啊.
谁能详细解释一下javabean到底有什么优势啊??
|