Java array copy to merge two arrays

Description

Java array copy to merge two arrays

import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    String[] names = new String[] { "HTML", "CSS", "SQL" };

    String[] extended = new String[5];

    extended[0] = "0";
    extended[1] = "1";
    extended[2] = "2";
    extended[3] = "3";
    extended[4] = "4";

    System.arraycopy(names, 0, extended, 0, names.length);

    System.out.println(Arrays.toString(names));
    System.out.println(Arrays.toString(extended));
  }//from  www.  j a  v  a  2s . co m
}



PreviousNext

Related