-2

I have two methods that make the same thing, but one receives a HashMap<Integer,double[]> and the other receive a HashMap<Integer,int[]>. How can I make this without to duplicate code.

fmassica
  • 1,896
  • 3
  • 17
  • 22

1 Answers1

0

Make two methods, one contains the real code, acception the version with the double-array and the other method, accepting the integer-version just calls this method but first converts the integer-array to a double array.

public void doSomething(HashMap<Integer, int[]> arg0) {

   //convert int[] to double[] and fill this HashMap
   HashMap<Integer, double[]> converted;

   doSomething(converted);
}

public void doSomething(HashMap<Integer, double[]> arg0) {

   //your logic here

}
rogi1609
  • 438
  • 3
  • 8