File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes method unavailable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "method unavailable" Watch "method unavailable" New topic
Author

method unavailable

Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 507
Class 1

Interface Implementation


Why I can not access getCount() method in Class 1? I thought methods/variables availability depends on the actual object and not on the reference type.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Saurabh Pillai wrote:Class 1

Interface Implementation


Why I can not access getCount() method in Class 1? I thought methods/variables availability depends on the actual object and not on the reference type.


Both come into play. All the compiler knows is that you have a reference to MyInterface. If you want to use something that was added in the impl, you have to cast it to that. However, doing so is probably a sign of a design flaw. If you intend to use it as an impl, because you know and care about details of that particular implementation, then you should have declared the variable as an impl.
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 507
Thank you Jeff.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method unavailable