• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

1 error when compiling PlayCode.java

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!)
 
reply
    Bookmark Topic Watch Topic
  • New Topic