500f2068d776001c10b28e19bbde48da
来自「用java编写的程序」· 代码 · 共 34 行
TXT
34 行
package webbook.beanutils.example;
public class BeanUtilsExample2 {
public static void main(String args[]) throws Exception {
BeanUtilsExampleV3 diff = new BeanUtilsExampleV3();
Actor actor = diff.prepareData();
Map describedData = BeanUtils.describe(actor);
// check the map
System.err.println(describedData.get("name"));
// change this value
describedData.put("name", "Robert Redford");
// create a new Actor Bean
Actor newActor = new Actor();
BeanUtils.populate(newActor, describedData);
System.err.println(BeanUtils.getProperty(newActor, "name"));
}
private Actor prepareData() {
Actor actor = new Actor();
actor.setName("Michael Caine");
actor.setGender(1);
actor.setWorth(10000000);
return actor;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?