Here is a very simple example:
private boolean f(List x) {
return x != null && !x.isEmpty();
}
private boolean f(Map x) {
return x != null && !x.isEmpty();
}
Code inside both function is same, they just operate on different objects. I want to merge them into one function to avoid code repeatation.
I tried something like:
private <T> boolean f(T x) {
return x != null && !x.isEmpty();
}
But it gives error on x.isEmpty()