Menyalin Nilai Array menggunakan CopyFrom dan CopyTo di Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package mengcopyarray;

/**
*
* @author uptti
*/
public class mengCopyArray {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
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);

for(int i=0; i<copyTo.length; i++){
System.out.println(i+". "+copyTo[i]);
}

}

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s