Home Tutorial Java Corejava Java arraycopy example- 2


Share on Google+Share on Google+
Java arraycopy example- 2
Posted on: April 9, 2010 at 12:00 AM
An arraycopy method in java copies an array from the specified source array, beginning or from the specified position, to the specified position of the destination array.


An arraycopy method have the following parameters.
arraycopy(Object source, int srcPositon, Object destination, int destPosition, int length). Here in this tutorial you will see a simple example of the arraycopy method of java.


public class ArrayCopyExample {
  public static void main(String[] args) {
    String[] characters = "A""B""C""D""E" };
    String[] copiedinto = new String[3];
    System.arraycopy(characters, 2, copiedinto, 03);
    for (int i = 0; i < copiedinto.length; i++) {
      System.out.println("result = " + copiedinto[i]);


result = C
result = D
result = E


Related Tags for Java arraycopy example- 2:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 9, 2010

Recommend the tutorial

Advertisements Advertisements