Is this an example of polymorphism?

Posted by computer-science-student on Stack Overflow See other posts from Stack Overflow or by computer-science-student
Published on 2010-03-27T20:51:08Z Indexed on 2010/03/27 20:53 UTC
Read the original article Hit count: 345

Filed under:
|
|

I'm working on a homework assignment (a project), for which one criterion is that I must make use of polymorphism in a way which noticeably improves the overall quality or functionality of my code.

I made a Hash Table which looks like this:

public class HashTable<E extends Hashable>{
    ...
}

where Hashable is an interface I made that has a hash() function.

I know that using generics this way improves the quality of my code, since now HashTable can work with pretty much any type I want (instead of just ints or Strings for example). But I'm not sure if it demonstrates polymorphism.

I think it does, because E can be any type that implements Hashable. In other words HashTable is a class which can work with (practically) any type.

But I'm not quite sure - is that polymorphism? Perhaps can I get some clarification as to what exactly polymorphism is?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about homework

Related posts about polymorphism