I am working on a code, containing the following lines:
 public static int[] toArray(List<Integer> list) {
   int[] array = new int[list.size()];
   for(int i = 0; i < array.length; i++)
     array[i] = list.get(i);
   return array;
 }
 public static double[] toArray(List<Double> list) {
   double[] array = new double[list.size()];
   for(int i = 0; i < array.length; i++)
     array[i] = list.get(i);
   return array;
 }
 public static String[] toArray(List<String> list) {
   String[] data = new String[list.size()];
   for(int i = 0; i < data.length; i++)
     data[i] = list.get(i);
   return data;
while compiling I get the following errors:
error: name clash: toArray(List<Double>) and toArray(List<Integer>) have the same erasure
 public static double[] toArray(List<Double> list) {
                        ^
error: name clash: toArray(List<String>) and toArray(List<Integer>) have the same erasure
 public static String[] toArray(List<String> list) {
                        ^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
This program is an open source program (and a bit old, 2006) that I recently downloaded. In the package I could find both binary version and the source code. It means that this code has been compiled correctly, but now I can not compile it.
Now I have 2 questions:
- What is wrong with this overloadings?
- How I can resolve this problem? May I replace these functions with just a function that is based on templates? If so, how?
Thanks
 
     
     
     
    