I have these pictures from Head First book:
I want you to pay attention to code that replaces ${person.dog.name}
. Only thing I want to know is how does it know that attribute "person" is object of type Person? Of course, getAttribute()
returns Object, so it must be casted to Person, but how does it know that it is made from Person class?
I guess this code uses findAttribute()
previously, to find scope where attribute with value "person" is stored. Later it tries to get it using getAttribute()
. So after it finds it, it gets it - but it still doesn't know what it is getting in reality. So how/where did it "figure out" that it is of type Person?