public class Contact {private String Name;private string tel;private attrcontrol attrc=new attrcontrol ();p rivate class att Rcontrol{public map<string,object> map=new HashMap ();p ublic Object isexist;public Map createattr (String a,String Value) {Object Obj= (object) Value;isexist=map.get (a); if (isexist==null) {map.put (a,obj);} Map.put (a,obj); return map;}} public void Setobj (String newattr,string value) {attrc.createattr (newattr,value);} Public Object getobj (String newattr) {Map a=attrc.map; return A.get (newattr);} public static void Main (string[] args) {Contact a =new contact () a.setobj ("Mail", "[e-mail protected]") a.setobj ("area", " 882 "); System.out.println ("Mail:" +string.valueof (A.getobj ("Mail")); System.out.println ("Area:" +integer.parseint (A.getobj ("area"). ToString ()));}}
At this point, you can dynamically put the property, and the value. It is just not permanent to save the attribute information, there is the word of the great God, can comment under.
Property set and get values for dynamically assigned Java classes