⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arrays.java

📁 this gcc-g++-3.3.1.tar.gz is a source file of gcc, you can learn more about gcc through this codes f
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    catch (NullPointerException e)      {        // If one is null, we get a harmless NullPointerException      }    return false;  }  /**   * Compare two char arrays for equality.   *   * @param a1 the first array to compare   * @param a2 the second array to compare   * @return true if a1 and a2 are both null, or if a2 is of the same length   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]   */  public static boolean equals(char[] a1, char[] a2)  {    // Quick test which saves comparing elements of the same array, and also    // catches the case that both are null.    if (a1 == a2)      return true;    try      {        // If they're the same length, test each element        if (a1.length == a2.length)          {            int i = a1.length;            while (--i >= 0)              if (a1[i] != a2[i])                return false;            return true;          }      }    catch (NullPointerException e)      {        // If one is null, we get a harmless NullPointerException      }    return false;  }  /**   * Compare two short arrays for equality.   *   * @param a1 the first array to compare   * @param a2 the second array to compare   * @return true if a1 and a2 are both null, or if a2 is of the same length   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]   */  public static boolean equals(short[] a1, short[] a2)  {    // Quick test which saves comparing elements of the same array, and also    // catches the case that both are null.    if (a1 == a2)      return true;    try      {        // If they're the same length, test each element        if (a1.length == a2.length)          {            int i = a1.length;            while (--i >= 0)              if (a1[i] != a2[i])                return false;            return true;          }      }    catch (NullPointerException e)      {        // If one is null, we get a harmless NullPointerException      }    return false;  }  /**   * Compare two int arrays for equality.   *   * @param a1 the first array to compare   * @param a2 the second array to compare   * @return true if a1 and a2 are both null, or if a2 is of the same length   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]   */  public static boolean equals(int[] a1, int[] a2)  {    // Quick test which saves comparing elements of the same array, and also    // catches the case that both are null.    if (a1 == a2)      return true;    try      {        // If they're the same length, test each element        if (a1.length == a2.length)          {            int i = a1.length;            while (--i >= 0)              if (a1[i] != a2[i])                return false;            return true;          }      }    catch (NullPointerException e)      {        // If one is null, we get a harmless NullPointerException      }    return false;  }  /**   * Compare two long arrays for equality.   *   * @param a1 the first array to compare   * @param a2 the second array to compare   * @return true if a1 and a2 are both null, or if a2 is of the same length   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]   */  public static boolean equals(long[] a1, long[] a2)  {    // Quick test which saves comparing elements of the same array, and also    // catches the case that both are null.    if (a1 == a2)      return true;    try      {        // If they're the same length, test each element        if (a1.length == a2.length)          {            int i = a1.length;            while (--i >= 0)              if (a1[i] != a2[i])                return false;            return true;          }      }    catch (NullPointerException e)      {        // If one is null, we get a harmless NullPointerException      }    return false;  }  /**   * Compare two float arrays for equality.   *   * @param a1 the first array to compare   * @param a2 the second array to compare   * @return true if a1 and a2 are both null, or if a2 is of the same length   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]   */  public static boolean equals(float[] a1, float[] a2)  {    // Quick test which saves comparing elements of the same array, and also    // catches the case that both are null.    if (a1 == a2)      return true;    // Must use Float.compare to take into account NaN, +-0.    try      {        // If they're the same length, test each element        if (a1.length == a2.length)          {            int i = a1.length;            while (--i >= 0)              if (Float.compare(a1[i], a2[i]) != 0)                return false;            return true;          }      }    catch (NullPointerException e)      {        // If one is null, we get a harmless NullPointerException      }    return false;  }  /**   * Compare two double arrays for equality.   *   * @param a1 the first array to compare   * @param a2 the second array to compare   * @return true if a1 and a2 are both null, or if a2 is of the same length   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]   */  public static boolean equals(double[] a1, double[] a2)  {    // Quick test which saves comparing elements of the same array, and also    // catches the case that both are null.    if (a1 == a2)      return true;    // Must use Double.compare to take into account NaN, +-0.    try      {        // If they're the same length, test each element        if (a1.length == a2.length)          {            int i = a1.length;            while (--i >= 0)              if (Double.compare(a1[i], a2[i]) != 0)                return false;            return true;          }      }    catch (NullPointerException e)      {        // If one is null, we get a harmless NullPointerException      }    return false;  }  /**   * Compare two Object arrays for equality.   *   * @param a1 the first array to compare   * @param a2 the second array to compare   * @return true if a1 and a2 are both null, or if a1 is of the same length   *         as a2, and for each 0 <= i < a.length, a1[i] == null ?   *         a2[i] == null : a1[i].equals(a2[i]).   */  public static boolean equals(Object[] a1, Object[] a2)  {    // Quick test which saves comparing elements of the same array, and also    // catches the case that both are null.    if (a1 == a2)      return true;    try      {        // If they're the same length, test each element        if (a1.length == a2.length)          {            int i = a1.length;            while (--i >= 0)              if (! AbstractCollection.equals(a1[i], a2[i]))                return false;            return true;          }      }    catch (NullPointerException e)      {        // If one is null, we get a harmless NullPointerException      }    return false;  }// fill  /**   * Fill an array with a boolean value.   *   * @param a the array to fill   * @param val the value to fill it with   */  public static void fill(boolean[] a, boolean val)  {    fill(a, 0, a.length, val);  }  /**   * Fill a range of an array with a boolean value.   *   * @param a the array to fill   * @param fromIndex the index to fill from, inclusive   * @param toIndex the index to fill to, exclusive   * @param val the value to fill with   * @throws IllegalArgumentException if fromIndex &gt; toIndex   * @throws ArrayIndexOutOfBoundsException if fromIndex &lt; 0   *         || toIndex &gt; a.length   */  public static void fill(boolean[] a, int fromIndex, int toIndex, boolean val)  {    if (fromIndex > toIndex)      throw new IllegalArgumentException();    for (int i = fromIndex; i < toIndex; i++)      a[i] = val;  }  /**   * Fill an array with a byte value.   *   * @param a the array to fill   * @param val the value to fill it with   */  public static void fill(byte[] a, byte val)  {    fill(a, 0, a.length, val);  }  /**   * Fill a range of an array with a byte value.   *   * @param a the array to fill   * @param fromIndex the index to fill from, inclusive   * @param toIndex the index to fill to, exclusive   * @param val the value to fill with   * @throws IllegalArgumentException if fromIndex &gt; toIndex   * @throws ArrayIndexOutOfBoundsException if fromIndex &lt; 0   *         || toIndex &gt; a.length   */  public static void fill(byte[] a, int fromIndex, int toIndex, byte val)  {    if (fromIndex > toIndex)      throw new IllegalArgumentException();    for (int i = fromIndex; i < toIndex; i++)      a[i] = val;  }  /**   * Fill an array with a char value.   *   * @param a the array to fill   * @param val the value to fill it with   */  public static void fill(char[] a, char val)  {    fill(a, 0, a.length, val);  }  /**   * Fill a range of an array with a char value.   *   * @param a the array to fill   * @param fromIndex the index to fill from, inclusive   * @param toIndex the index to fill to, exclusive   * @param val the value to fill with   * @throws IllegalArgumentException if fromIndex &gt; toIndex   * @throws ArrayIndexOutOfBoundsException if fromIndex &lt; 0   *         || toIndex &gt; a.length   */  public static void fill(char[] a, int fromIndex, int toIndex, char val)  {    if (fromIndex > toIndex)      throw new IllegalArgumentException();    for (int i = fromIndex; i < toIndex; i++)      a[i] = val;  }  /**   * Fill an array with a short value.   *   * @param a the array to fill   * @param val the value to fill it with   */  public static void fill(short[] a, short val)  {    fill(a, 0, a.length, val);  }  /**   * Fill a range of an array with a short value.   *   * @param a the array to fill   * @param fromIndex the index to fill from, inclusive   * @param toIndex the index to fill to, exclusive   * @param val the value to fill with   * @throws IllegalArgumentException if fromIndex &gt; toIndex   * @throws ArrayIndexOutOfBoundsException if fromIndex &lt; 0   *         || toIndex &gt; a.length   */  public static void fill(short[] a, int fromIndex, int toIndex, short val)  {    if (fromIndex > toIndex)      throw new IllegalArgumentException();    for (int i = fromIndex; i < toIndex; i++)      a[i] = val;  }  /**   * Fill an array with an int value.   *   * @param a the array to fill   * @param val the value to fill it with   */  public static void fill(int[] a, int val)  {    fill(a, 0, a.length, val);  }  /**   * Fill a range of an array with an int value.   *   * @param a the array to fill   * @param fromIndex the index to fill from, inclusive   * @param toIndex the index to fill to, exclusive   * @param val the value to fill with   * @throws IllegalArgumentException if fromIndex &gt; toIndex   * @throws ArrayIndexOutOfBoundsException if fromIndex &lt; 0   *         || toIndex &gt; a.length   */  public static void fill(int[] a, int fromIndex, int toIndex, int val)  {    if (fromIndex > toIndex)      throw new IllegalArgumentException();    for (int i = fromIndex; i < toIndex; i++)      a[i] = val;  }  /**   * Fill an array with a long value.   *   * @param a the array to fill   * @param val the value to fill it with   */  public static void fill(long[] a, long val)  {    fill(a, 0, a.length, val);  }  /**   * Fill a range of an array with a long value.   *   * @param a the array to fill   * @param fromIndex the index to fill from, inclusive   * @param toIndex the index to fill to, exclusive   * @param val the value to fill with   * @throws IllegalArgumentException if fromIndex &gt; toIndex   * @throws ArrayIndexOutOfBoundsException if fromIndex &lt; 0   *         || toIndex &gt; a.length   */  public static void fill(long[] a, int fromIndex, int toIndex, long val)  {    if (fromIndex > toIndex)      throw new IllegalArgumentException();    for (int i = fromIndex; i < toIndex; i++)      a[i] = val;  }  /**   * Fill an array with a float value.   *   * @param a the array to fill   * @param val the value to fill it with   */  public static void fill(float[] a, float val)  {    fill(a, 0, a.length, val);  }  /**   * Fill a range of an array with a float value.   *   * @param a the array to fill   * @param fromIndex the index to fill from, inclusive   * @param toIndex the index to fill to, exclusive

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -