[Java] Generic Method vs Method Overloading | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

[Java] Generic Method vs Method Overloading

What's the difference between Generic and Overloading in java ? When should I use Generic and When should I use Overloading ? https://code.sololearn.com/c55P1PJmAnwl/?ref=app

29th Aug 2017, 3:00 PM
Corey
Corey - avatar
1 Answer
+ 8
Generics are used for type safety and to avoid casting, they don't replace overloading which means to define a specific behaviour depending on the arguments. I think this will help you to understand the differences: http://docs.oracle.com/javase/tutorial/extra/generics/intro.html
31st Aug 2017, 8:12 AM
Tashi N
Tashi N - avatar