aspose file tools*
The moose likes Beginning Java and the fly likes Interfaces, I never learned those in school.  Can someone help me? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interfaces, I never learned those in school.  Can someone help me?" Watch "Interfaces, I never learned those in school.  Can someone help me?" New topic
Author

Interfaces, I never learned those in school. Can someone help me?

Rooks Forgenal
Ranch Hand

Joined: Jun 05, 2009
Posts: 82
Though the subject says i never learned them, I feel the need to say it was not for lack of trying on the professors part. These just proved to be over my head at the time. So, why bothering to learn after the class is long gone you ask? Well, someone asked me how to do them assuming that I would know. The further I got in to trying to help, the more I realized, I have no idea what I was talking about and I said as much to the help requester. This leads me to this forum. With the awesomeness that is NetBeans, I made this interface from a state of pure ignorance with IntelliSense. I am now a true fanboy of NetBeans. So sorry Eclipse and Visual Studio.

Here is my interface.


Now here is my question. Let us just say that the Iterator methods (like hasNext) were implemented already and let's say that the interface has some more sophistication. It should look like a hash table or something like that. It doesn't matter for my question. If I instantiate the extendIter object in Main, and set it to a variable with type ITTR; will I now be able to use the iterator over my hash table, linked list, array?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11243
    
  16

all that an interface is is a contract. the person who writes the 'public interface XYX' file defines what methods MUST be implemented.

The person who writes the code '<whatever> class ABC implements XYZ' must have those methods defined in their class.

That's it. The methods can be empty, they can be inherited from a superclass, they can do something contrary to what the interface says they should do...it doesn't matter. They just have to be defined.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
 
subject: Interfaces, I never learned those in school. Can someone help me?