在我的项目中,我有一个小的数据结构Key.
public class Key implements Serializable {
private static final long serialVersionUID = 1L;
public String db;
public String ref;
public Object id;
protected Key() {
}
public Key(String db, String ref, Object id) {
this.db = db;
this.ref = ref;
this.id = id;
}
}
Run Code Online (Sandbox Code Playgroud)
是的,这个课程很简单,每个领域都可公开访问.
但有人建议我使用POJO风格的课程,但当我问他们为什么无法告诉我.
在我看来,调用getter和setter比直接访问字段要慢.
那么为什么我必须使用POJO编程风格呢?