• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

1 error when compiling PlayCode.java

 
Shanel Jacob
Ranch Hand
Posts: 112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I got this error - "cannot resolve symbol ... myInterfaceReference.sayHelloFromMyClass()". Any comments would be great!


[ July 19, 2006: Message edited by: Shanel Jacob ]
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is true that the return type of the method getMyClass() is MyInterface, and MyClass implements MyInterface.

However, the method sayHelloFromMyClass() is not a member of MyInterface, so unless you cast myInterfaceReference to a MyClass reference, or add the method header of sayHelloFromMyClass() to MyInterface, you can't call sayHelloFromMyClass() with myInterfaceReference.
[ July 19, 2006: Message edited by: Keith Lynn ]
 
Daniel Bryant
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I totally agree with Keith. I think what you mean to code was



or if you wanted to explore the casting Keith mentioned you could alter your main method to:




Daniel
 
Shanel Jacob
Ranch Hand
Posts: 112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Keith and Daniel, I tried both suggested fix and managed to compile without errors. Thank you very much (again!)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic