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