I have code that looks like this:
for(int i=0; i < a; i++){
List<Integer> list = elementA.get(i);
SomeClass rg = new SomeClass(list, a, methodA(i));
int result = rg.generate();
var+=methodA2(i, result);
}
for(int i=0; i < b; i++){
List<Integer> list = elementB.get(i);
SomeClass rg = new SomeClass(list, b, methodB(i));
int result = rg.generate();
var+=methodB2(i, result);
}
How can I avoid this code repetition? I can create function which does that, but what to do with this different methods?