Java Arrays排序short索引


Java Arrays排序short索引

package com.codingdict;

import java.util.Arrays;

public class ArrayDemo {
   public static void main(String[] args) {

      // initializing unsorted short array
      short sArr[] = {3, 13, 1, 9, 21};

      // let us print all the elements available in list
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }

      // sorting array from index 1 to 4
      Arrays.sort(sArr, 1, 4);

      // let us print all the elements available in list
      System.out.println("short array with some sorted values(1 to 4) is:");
      for (short number : sArr) {
         System.out.println("Number = " + number);
      }
   }
}