mardi 13 janvier 2015

Is there any way to initialize variables from object and class names?(such as by using reflections)

For example: let us say there is a class Dog , a subclass Dalmatian and the Dog class has private variables String name, breed; Now I say in main:



Dog spot = new Dalamatian();


and automatically it get name = "spot" and breed = "Dalmatian".






Aucun commentaire:

Enregistrer un commentaire