Thanks for your reply. I didn't do a good job asking the question. I can rewrite the code and eliminate the errors I mentioned by changing the reference variable type from Name to Object.
I want to cast the Object to Name so I can use its methods but the complier still thinks n1 and n2 are Objects not Names.
I'm sure I'm missing something fundamental but it escapes me.
Thanks for yor help.
Your casting incorrectly. The dot operator has precedence over the cast, so you have to modify the order to ensure you cast first, then call the method on the casted reference. Do it using parenthesis:
Joined: Feb 10, 2007
My worst fears have been realized. My problem was trivial. Oh well! Nothing to do but press on.
Thanks to you guys for your help.
I get two errors Name (or firstnameSort) is not abstract (OK I buy that) and does not override abstract method compare (or compareTo) (looks to me like they do)...
This error is basically given when the compiler finds that you are not fulfilling the contract of the interface(concrete classes should implement all methods of the interface). May be a quick look at the java1.4 api docs would have solved the problem there and then.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api