Field is just a description of the field, it is not the value contained there.
You need to get the value first, and then you can say it:
Card x = (Card) field.get(this);
Also, you probably want to allow subclasses as well, so you should do
// if (field.getType() == Card.class) { if (Card.class.isAssignableFrom(field.getType()) {
Thilo
source share