jdk/src/java.base/share/classes/java/util/Arrays.java
changeset 31678 7a5da9274448
parent 31540 6efd719b3330
parent 31671 362e0c0acece
child 32108 aa5490a167ee
equal deleted inserted replaced
31564:9b3a9d72f07b 31678:7a5da9274448
    40 import java.util.stream.DoubleStream;
    40 import java.util.stream.DoubleStream;
    41 import java.util.stream.IntStream;
    41 import java.util.stream.IntStream;
    42 import java.util.stream.LongStream;
    42 import java.util.stream.LongStream;
    43 import java.util.stream.Stream;
    43 import java.util.stream.Stream;
    44 import java.util.stream.StreamSupport;
    44 import java.util.stream.StreamSupport;
       
    45 import jdk.internal.HotSpotIntrinsicCandidate;
    45 
    46 
    46 /**
    47 /**
    47  * This class contains various methods for manipulating arrays (such as
    48  * This class contains various methods for manipulating arrays (such as
    48  * sorting and searching). This class also contains a static factory
    49  * sorting and searching). This class also contains a static factory
    49  * that allows arrays to be viewed as lists.
    50  * that allows arrays to be viewed as lists.
  2652      *
  2653      *
  2653      * @param a one array to be tested for equality
  2654      * @param a one array to be tested for equality
  2654      * @param a2 the other array to be tested for equality
  2655      * @param a2 the other array to be tested for equality
  2655      * @return <tt>true</tt> if the two arrays are equal
  2656      * @return <tt>true</tt> if the two arrays are equal
  2656      */
  2657      */
       
  2658     @HotSpotIntrinsicCandidate
  2657     public static boolean equals(char[] a, char[] a2) {
  2659     public static boolean equals(char[] a, char[] a2) {
  2658         if (a==a2)
  2660         if (a==a2)
  2659             return true;
  2661             return true;
  2660         if (a==null || a2==null)
  2662         if (a==null || a2==null)
  2661             return false;
  2663             return false;
  3203      * @throws ArrayStoreException if an element copied from
  3205      * @throws ArrayStoreException if an element copied from
  3204      *     <tt>original</tt> is not of a runtime type that can be stored in
  3206      *     <tt>original</tt> is not of a runtime type that can be stored in
  3205      *     an array of class <tt>newType</tt>
  3207      *     an array of class <tt>newType</tt>
  3206      * @since 1.6
  3208      * @since 1.6
  3207      */
  3209      */
       
  3210     @HotSpotIntrinsicCandidate
  3208     public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
  3211     public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
  3209         @SuppressWarnings("unchecked")
  3212         @SuppressWarnings("unchecked")
  3210         T[] copy = ((Object)newType == (Object)Object[].class)
  3213         T[] copy = ((Object)newType == (Object)Object[].class)
  3211             ? (T[]) new Object[newLength]
  3214             ? (T[]) new Object[newLength]
  3212             : (T[]) Array.newInstance(newType.getComponentType(), newLength);
  3215             : (T[]) Array.newInstance(newType.getComponentType(), newLength);
  3472      * @throws ArrayStoreException if an element copied from
  3475      * @throws ArrayStoreException if an element copied from
  3473      *     <tt>original</tt> is not of a runtime type that can be stored in
  3476      *     <tt>original</tt> is not of a runtime type that can be stored in
  3474      *     an array of class <tt>newType</tt>.
  3477      *     an array of class <tt>newType</tt>.
  3475      * @since 1.6
  3478      * @since 1.6
  3476      */
  3479      */
       
  3480     @HotSpotIntrinsicCandidate
  3477     public static <T,U> T[] copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType) {
  3481     public static <T,U> T[] copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType) {
  3478         int newLength = to - from;
  3482         int newLength = to - from;
  3479         if (newLength < 0)
  3483         if (newLength < 0)
  3480             throw new IllegalArgumentException(from + " > " + to);
  3484             throw new IllegalArgumentException(from + " > " + to);
  3481         @SuppressWarnings("unchecked")
  3485         @SuppressWarnings("unchecked")