Copy some items of an array into another array in Java
Description
The following code shows how to copy some items of an array into another array.
Example
/* w w w. j av a2 s. co m*/
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
String[] letters = { "A", "I", "U", "E", "O" };
String[] results = new String[3];
System.arraycopy(letters, 2, results, 0, 3);
System.out.println(Arrays.toString(results));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »