I want to create a toString() method that works for any class, printing all its attributes as if it worked like this:
String toString(){
for(Attribute att: this.Attributes){
System.out.println(att.name + ": " + att.toString());
}
}
But this would work supposing all attributes have toString() method, so let's keep this supposition.
I guess this question includes concepts of reflection, and I don't know much about this concept nor how to apply this in Java.
Aucun commentaire:
Enregistrer un commentaire