标签:object field public rac turn gtd get pack pen
package ch09
import java.lang.reflect.Field;
class DataObject{
private String name;
private String desc;
private int age;
private String other;
public DataObject (String name,String desc,int age , String other){
super();
this.name=name;
this.desc=desc;
this.age=age;
this.other=other;
}
public String toString(){
StringBuffer sb=new StringBuffer();
Field[] fields=this.geClass().gtDeclaredFields();
for(Field f:fields){
sb.append(f.getName());
sb.append("=");
try{
ab.append(f.get(this));
}catch(IllegalArgumentException e){
e.printStackTrace();
}
catch(IllegalAccessException e){
e.printStackTrace();
}
sb.append("\n");
}
return sb.toString();
}
}
标签:object field public rac turn gtd get pack pen
原文地址:https://www.cnblogs.com/xiaohaizhuimeng/p/8989824.html