Java Arrays sort 方法 - 排序byte


Java Arrays sort 方法 - 排序byte

package com.codingdict;

import java.util.Arrays;

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

      // initializing unsorted byte array
      byte bArr[] = {10,7,4,37,29};

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

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

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