Java Array class copyOfRange(int[] original, int from, int to) example
Array class copyOfRange(int[] original, int from, int to) method example
Array class copyOfRange(int[] original, int from, int to)method example. This example shows you how to use copyOfRange(int[] original, int from, int to) method.This method Copies the specified range of the specified array into a new array.
Here is the code:-
/**
* @Program that Copies the specified range of the specified array into a new
* array.
* CopyofRange5Array.java
* Author:-RoseIndia Team
* Date:-15-May-2008
*/
import java.util.*;
public class CopyofRange5Array {
public static void main(String[] args) {
//creating a Integer array
int b[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 3};
// //Copies the specified Integer array upto specified range,
int b1[] = Arrays.copyOfRange(b, 5, 8);
for (int i = 0; i < b1.length; i++) //Displaying the Copied Integer array upto specified range
{
System.out.println(b1[i]);
}
}
} |
|