My question is: is it possible to make one generic method where I can use 2 different types? E.g. an Integer and a String.
There is no practical use for this, but I'd just like to know if it's possible. And if it is, how? :)
You dont need to use generics for this. You can overload the methods. For example
public void method(Integer i){}
public void method(String s){}
If you call method with an integer then it will call the first method. If you call it with a string it will call the second method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With