Powered by Blogger.

Array copy Optimization in Java Program

Array copy Optimization:

In Java technology, all array indexes begin at 0. The number of elements in an array is stored as part of the array object in the length attribute. If an out-of-bounds runtime access occurs, then a runtime exception is thrown. After array id created, you cannot resize an array. However, you can use the same reference variable to refer to an entirely new array. Java provides a special method in the System class, arraycopy() to copy arrays.


Array Copy Example:-

 public void arrayCopy(){
 int[] x = {1,2,3,4,5,6};
 int[] y = {11,12,13,14,15,16,17,18,19,20};
 System.arraycopy(x,0,y,0,x.length);
  }
 }

Arraycopy method that you can use to efficiently copy data from one array into another:

public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

2 comments:

  1. Pretty good post. I just came across your site and wanted to say that I’ve really enjoyed reading your posts. In any case I’ll be subscribing to your feed and I hope you will keep a good work!Cheer!

    sap online training
    software online training
    sap sd online training
    hadoop online training
    sap-crm-online-training

    ReplyDelete
  2. This is one awesome blog article. Much thanks again.
    I really enjoy the blog.Much thanks again. Really Great.


    oracle online training
    sap fico online training
    dotnet online training
    qa-qtp-software-testing-training-tutorial

    ReplyDelete