Java Arrayclass copyOfRange(boolean[]original, int from, int to) example
Array class copyOfRange(boolean[] original, int from, int to)method example
Array class copyOfRange(boolean[] original, int from, int to) method example. This example shows you how to use copyOfRange(boolean[] 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
* CopyofRangeArray.java
* Author:-RoseIndia Team
* Date:-15-May-2008
*/
import java.util.*;
public class CopyofRangeArray {
public static void main(String[] args) {
//creating a boolean array
boolean b[] = {true, false, true, false, false, true, true, true, false};
// //Copies the specified boolean array upto specified range,
boolean b1[] = Arrays.copyOfRange(b, 5, 8);
for (int i = 0; i < b1.length; i++) {
//Displaying the Copied boolean array upto specified range
System.out.println(b1[i]);
}
}
} |
|