How do I create an instance a JavaBean?
程序员文章站
2022-04-24 14:19:38
...
package org.kodejava.example.bean;
import java.io.Serializable;
import java.io.IOException;
import java.beans.Beans;
public class TheBean implements Serializable {
private Long id;
private String name;
public TheBean() {
}
public static void main(String[] args) {
try {
TheBean bean = (TheBean) Beans.instantiate(
ClassLoader.getSystemClassLoader(), "org.kodejava.example.bean.TheBean");
System.out.println("The Bean = " + bean);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "[id=" + id + "; name=" + name + "]";
}
}
转载于:https://my.oschina.net/jsan/blog/57640
上一篇: Hibernate框架双向多对多配置,以及级联操作
下一篇: How do I programmatically create a TouchEvent in Chrome ?[JavaScript jQuery 模拟点击操作]
推荐阅读
-
how dude do i look官网地址是什么
-
how old do i look(how-old.net)怎么玩?HowOldRobot怎么测年龄
-
How do I change MySQL timezone?
-
How do I change MySQL timezone?_PHP教程
-
how dude do i look官网地址是什么
-
how old do i look(how-old.net)怎么玩?HowOldRobot怎么测年龄
-
How do I change MySQL timezone?_php技巧
-
How do I change MySQL timezone?_PHP教程
-
How do I change MySQL timezone?
-
How do I change MySQL timezone?_php技巧