-
June 26th, 2012, 11:26 AM
#1
Polymorphism without inheritance in java
Hi,
Can any one please explain how to implement polymorphism without inheritance in java.
It would be useful if it is explained starting with what is polymorphism, types of polymorphism and polymosrphism with inheritance and without inheritance.
Thanks
-
June 26th, 2012, 12:20 PM
#2
Re: Polymorphism without inheritance in java
Originally Posted by AmyJose
how to implement polymorphism
Polymorphism literally means "many forms" and it's not something you implement really. It's part of the language or rather of the type system of the language. The purpose is to make it more flexible. A monomorphic language would be very tedious to work with.
in Java there are four different kinds: subtype polymorphism (by the way of inheritance and overriding), parametric polymorphism (basically generics), method overloading and finally coersion (types automatically "sliding" into each other).
Last edited by nuzzle; June 26th, 2012 at 03:20 PM.
-
June 28th, 2012, 04:32 AM
#3
Re: Polymorphism without inheritance in java
Originally Posted by AmyJose
Hi,
Can any one please explain how to implement polymorphism without inheritance in java.
It would be useful if it is explained starting with what is polymorphism, types of polymorphism and polymosrphism with inheritance and without inheritance.
Thanks
Can't you be a little more specific?
I don't want to be rude, but if you know nothing about a concept you should first read a manual or a book and then, ask what you don't understand, don't you think?
This is a good place to get help when you are stuck, when you have a concrete problem or when you don't understand something, but we can't explain how OOP (Object-oriented programming) works, and polymorphism is a basic part of OOP.
Nevertheless, you can find a very simple self-explanatory example in Wikipedia. You can also check java.util.List interface and their implementations: LinkedList and ArrayList. Both are a good starting point to understand how polymorphism works.
Albert.
Please, correct me. I'm just learning.... and sorry for my english :-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|