• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rooks Forgenal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic