Question

java question have a clear and detailed explanation for rating What is parameterized types/generics? Explain how...

java question

have a clear and detailed explanation for rating

What is parameterized types/generics? Explain how it eliminates the need for downcasting?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In Java, a generic type is a reference type that lets you define a class or a function without mentioning the actual type. These generic type is then replaced by the actual type while declaring an object of the class or using the method.

A parameterized type is an instantiation of a generic type with actual type arguments.

Now, we do downcasting when we want to change one type to one of its subtype. For example, we can downcast Long to Integer.

Now with generic types, we dont actually need to downcast, what we can do is provide the actual parameterized types while instantiating the generic types.

Add a comment
Know the answer?
Add Answer to:
java question have a clear and detailed explanation for rating What is parameterized types/generics? Explain how...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT