0

I made this method to concatenate 3 arrays of Strings but when i obtain the final array it dosen't containg all the data inside.

   public String[] obtainFullArrayOfCounter(String first[], String second[], String third[]) {
    String finalArray[] = new String[first.length + second.length + third.length];
    System.arraycopy(finalArray, 0, finalArray, 0, first.length);
    System.arraycopy(second, 0, finalArray, first.length, second.length);
    System.arraycopy(third, 0, finalArray, first.length + second.length, third.length);


    return finalArray;

}

Thanks for help

  • 3
    `System.arraycopy(finalArray, 0, finalArray, ` is strange src = dest –  Nov 20 '17 at 10:35
  • what do you mean with is strange src=dest? –  Nov 20 '17 at 11:00
  • see https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#arraycopy-java.lang.Object-int-java.lang.Object-int-int- first and third arg is the same (`finalArray`) and that's "strange" –  Nov 20 '17 at 12:15

0 Answers0