Java Array class copyOfRange(T[] original, int from, int to) example
Array class copyOfRange(T[] original, int from, int to) method example
Array class copyOfRange(T[] original, int from, int to) method example.This example shows you how to use copyOfRange(T[] 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.
* CopyofRange8Array.java
* Author:-RoseIndia Team
* Date:-15-May-2008
*/
import java.util.*;
public class CopyofRange8Array {
public static void main(String[] args) {
//creating a short array
Object T[]={"Rose","India","Net","Limited","Rohini"};
// //Copies the specified short array upto specified range,
Object T1[] = Arrays.copyOfRange(T, 1,5);
for (int i = 0; i < T1.length; i++)
//Displaying the Copied short array upto specified range
System.out.println(T1[i]);
}
} |
|