Quantcast
Viewing all articles
Browse latest Browse all 11

Answer by Ambika for What is more efficient: System.arraycopy or Arrays.copyOf?

      class ArrayCopyDemo {
   public static void main(String[] args) {
    char[] copyFrom = { 'd', 'e', 'c', 'a', 'f', 'f', 'e',
            'i', 'n', 'a', 't', 'e', 'd' };
    char[] copyTo = new char[7];

    System.arraycopy(copyFrom, 2, copyTo, 0, 7);
    System.out.println(new String(copyTo));
}
 }

Viewing all articles
Browse latest Browse all 11

Trending Articles