Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Copying Arrays Using copyOfRange() method Java

// To use toString() and copyOfRange() method
import java.util.Arrays;

class ArraysCopy {
    public static void main(String[] args) {
      
        int[] source = {2, 3, 12, 4, 12, -2};
      
        // copying entire source array to destination
        int[] destination1 = Arrays.copyOfRange(source, 0, source.length);      
        System.out.println("destination1 = " + Arrays.toString(destination1)); 
      
        // copying from index 2 to 5 (5 is not included) 
        int[] destination2 = Arrays.copyOfRange(source, 2, 5); 
        System.out.println("destination2 = " + Arrays.toString(destination2));   
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java join list of strings 
Java :: how to the text of an element in selenium java 
Java :: how to create a random number in java 
Java :: array to list 
Java :: system.out.println shortcut 
Java :: date java format 
Java :: android hide status bar and action bar daynamically 
Java :: java 8 group a collections by 2 property 
Java :: get logged-in user in Spring Security 
Java :: java print output 
Java :: float random class java 
Java :: iterator for array java 
Java :: startactivityforresult deprecated android 
Java :: java gui 
Java :: link to method javadoc 
Java :: list to array java 
Java :: spigot how to kill player 
Java :: recyclerview stop scrolling 
Java :: rps java 
Java :: how to do stuff with a scoreboard minecraft 
Java :: iterating over a hashmap 
Java :: how to make int array java android 
Java :: how to add elements to an array in java dynamically 
Java :: len of number in java 
Java :: Java List Sort Using sort() method 
Java :: byte array to base64 string 
Java :: javafx stackpane set position 
Java :: change number into array in java 
Java :: java arraylist loop 
Java :: calculator with java 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =