arrays.copy ofSlider/numberShuffle.htm?rows=3&cols=3&sqr=1 code example

Example: Arrays copyOfRange() method in java

// arrays copyofrange short data type example
import java.util.Arrays;
public class ArrayCopyShort
{
   public static void main(String[] args)
   {
      short[] arrShort1 = new short[] {14, 23, 41};
      System.out.println("ARRAY COPY OF RANGE METHOD - SHORT DATA TYPE");
      System.out.println("--------------------------------------------");
      System.out.println("Given array : ");
      for(int a = 0; a < arrShort1.length; a++)
      {
         System.out.println(arrShort1[a]);
      }
      // java copyofrange
      short[] arrShort2 = Arrays.copyOfRange(arrShort1, 1, 3);
      System.out.println("Copied array : ");
      for(int a = 0; a < arrShort2.length; a++)
      {
         System.out.println(arrShort2[a]);
      }
   }
}

Tags:

Java Example