Forums Register Login

importance of formal type parameters?

+Pie Number of slices to send: Send


what is the importance of formal type parameters..??

why are they used..??



please help...
thanks in advance..
+Pie Number of slices to send: Send
Suppose you have a non-generic method

now this is too general in the sense that it does not express any relationship between k and array this kind of dependency can be achieved using formal type parameter



so now when a generic method is called you can specify the E as you wish like Integer and hence k and array will be of type Integer, for example


this means the call signature is : iAmGeneric(Integer, Integer[])


i hope you got it

Ankit
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1650 times.
Similar Threads
Removing items in an iterator
Type argument inference in Generics
Generics refresher
Generic methods doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:37:21.