I need the following functionality
Given two sorted lists, merge them
I have this skeleton Java code:
public class MergeLists{
public List merge(List l1, List l2){
List l3;
// merge l1, l2 in to l3
return l3;
}
public static void main(){
// populate list1 and list2
MergeLists ml = new MergeLists();
List l3 = ml.merge(l1,l2);
}
}
Is this single method class the right approach? I feel like the almost-empty class is staring at me to say that this is bad design. I initially had List L3 as private member of MergeLists but then I thought, merge(l1,l2) can be called multiple times with the same object, which required l3 to be local to merge(l1,l2). I read that using static method is even worse for code re-usability. Please advise. Thank you.