package com.www;
public class Cola {
private String name;
public String press;
public int price;
public Cola() {
super();
// TODO Auto-generated constructor stub
}
public Cola(String name, String press, int price) {
super();
this.name = name;
this.press = press;
this.price = price;
}
@Override
public String toString() {
return "Pepsi [name=" + name + ", press=" + press + ", price=" + price
+ "]";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPress() {
return press;
}
public void setPress(String press) {
this.press = press;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}
package com.www;
public class Pepsi {
private String name="百事可乐";
public String press="百事公司";
public int price=2;
public Pepsi() {
super();
// TODO Auto-generated constructor stub
}
public Pepsi(String name, String press, int price) {
super();
this.name = name;
this.press = press;
this.price = price;
}
@Override
public String toString() {
return "Pepsi [name=" + name + ", press=" + press + ", price=" + price
+ "]";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPress() {
return press;
}
public void setPress(String press) {
this.press = press;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}
package com.www;
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.beanutils.BeanUtils;
public class Test {
public static void main(String[] args) throws Exception, InvocationTargetException {
Pepsi p = new Pepsi();
Cola c = new Cola();
BeanUtils.copyProperties(c, p);
System.out.println(c.getName());
System.out.println(c.getPress());
System.out.println(c.getPrice());
}
}
Evolution forged the entirety of Sentient life on this planet using only one tool— the mistake.进化形成了这个星球上有感情和知觉的生命体用的唯一的工具,就是错误。
《西部世界》