• 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

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

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic