ohhhhhh, We're on the same page, we just don't think we are.
Oh yeah, I get that the cast doesn't really do anything it's just there to mess you up on the mock ? I had. (I read in a couple of books that it's good practice to put it there so other programmers know you meant to do it - well, if you didn't mean to do it then why did you do it). Same thing occurs if you leave out the cast too!
// again, the cast in the above statement is not needed// and changes absolutely NOTHING at all. // subcl1 and super1 are both references to a // superclass and they now reference // THE SAME OBJECT: Object #2.// In fact, since nothing references Object #1 // at this point, it is now eligible for garbage collection// So at this point you only have one Object: Object #2, a superclass
I couldn't agree more. I'm sorry, I've been studying too much and maybe didn't express myself too well. In my head I'm making a distinction between the variable and the type. I should have made it clear that it is the references and not the Objects that are changing types. The references compile-time type and run-time type are different, Objects stay the same.
I just passed
scjp 1.4 this morning...And let's just say that this discussion may have gotten me a much needed point, so big big thanks guys!!!
[ September 17, 2002: Message edited by:
Alan Phillips ]