Suppose I have the class
class car { int color = 1; seats carSeats = new seats(); class seats { int numSeats = 4; } } Using Java reflection, I can use the following:
car c = new car(); Field[] carFields = c.getClass().getDeclaredFields(); carFields would have { color, carSeats } as the fields. The instance, carSeats, has another field called numSeats.
Technically, I should be able to do another getFields() operation such that:
Field[] seatFields = carFields[1].getClass().getDeclaredFields(); But I am given garbage data (DECLARED, PUBLIC?) Why so? Does Java reflection not work for inner classes?
carFields[1]: fields are not by definition ordered!