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

📄 array.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
   * @return the int element at <code>array[index]</code>   * @throws IllegalArgumentException  if <code>array</code> is not a byte,   *         char, short, or int array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #get(Object, int)   */  public static native int getInt(Object array, int index);  /**   * Gets an element of a long array.   *   * @param array the array to access   * @param index the array index to access   * @return the long element at <code>array[index]</code>   * @throws IllegalArgumentException  if <code>array</code> is not a byte,   *         char, short, int, or long array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #get(Object, int)   */  public static native long getLong(Object array, int index);  /**   * Gets an element of a float array.   *   * @param array the array to access   * @param index the array index to access   * @return the float element at <code>array[index]</code>   * @throws IllegalArgumentException  if <code>array</code> is not a byte,   *         char, short, int, long, or float array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #get(Object, int)   */  public static native float getFloat(Object array, int index);  /**   * Gets an element of a double array.   *   * @param array the array to access   * @param index the array index to access   * @return the double element at <code>array[index]</code>   * @throws IllegalArgumentException  if <code>array</code> is not a byte,   *         char, short, int, long, float, or double array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #get(Object, int)   */  public static native double getDouble(Object array, int index);  private static native Class getElementType(Object array, int index);  private static native void set(Object array, int index,				  Object value, Class elType);  /**   * Sets an element of an array. If the array is primitive, then the new   * value is unwrapped and widened.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not an array,   *         or the array is primitive and unwrapping value fails, or the   *         value is not assignable to the array component type   * @throws NullPointerException if array is null, or if array is primitive   *         and value is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #setBoolean(Object, int, boolean)   * @see #setByte(Object, int, byte)   * @see #setChar(Object, int, char)   * @see #setShort(Object, int, short)   * @see #setInt(Object, int, int)   * @see #setLong(Object, int, long)   * @see #setFloat(Object, int, float)   * @see #setDouble(Object, int, double)   */  public static void set(Object array, int index, Object value)  {    Class elType = getElementType(array, index);    if (! elType.isPrimitive())      set(array, index, value, elType);    else if (value instanceof Byte)      setByte(array, index, ((Byte) value).byteValue());    else if (value instanceof Short)      setShort(array, index, ((Short) value).shortValue());    else if (value instanceof Integer)      setInt(array, index, ((Integer) value).intValue());    else if (value instanceof Long)      setLong(array, index, ((Long) value).longValue());    else if (value instanceof Float)      setFloat(array, index, ((Float) value).floatValue());    else if (value instanceof Double)      setDouble(array, index, ((Double) value).doubleValue());    else if (value instanceof Character)      setChar(array, index, ((Character) value).charValue());    else if (value instanceof Boolean)      setBoolean(array, index, ((Boolean) value).booleanValue());    else      throw new IllegalArgumentException();  }  /**   * Sets an element of a boolean array.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not a boolean   *         array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #set(Object, int, Object)   */  public static native void setBoolean(Object array, int index, boolean value);  /**   * Sets an element of a byte array.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not a byte,   *         short, int, long, float, or double array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #set(Object, int, Object)   */  public static native void setByte(Object array, int index, byte value);  /**   * Sets an element of a char array.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not a char,   *         int, long, float, or double array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #set(Object, int, Object)   */  public static native void setChar(Object array, int index, char value);  /**   * Sets an element of a short array.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not a short,   *         int, long, float, or double array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #set(Object, int, Object)   */  public static native void setShort(Object array, int index, short value);  /**   * Sets an element of an int array.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not an int,   *         long, float, or double array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #set(Object, int, Object)   */  public static native void setInt(Object array, int index, int value);  /**   * Sets an element of a long array.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not a long,   *         float, or double array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #set(Object, int, Object)   */  public static native void setLong(Object array, int index, long value);  /**   * Sets an element of a float array.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not a float   *         or double array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #set(Object, int, Object)   */  public static native void setFloat(Object array, int index, float value);  /**   * Sets an element of a double array.   *   * @param array the array to set a value of   * @param index the array index to set the value to   * @param value the value to set   * @throws IllegalArgumentException if <code>array</code> is not a double   *         array   * @throws NullPointerException if <code>array</code> is null   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of   *         bounds   * @see #set(Object, int, Object)   */  public static native void setDouble(Object array, int index, double value);}

⌨️ 快捷键说明

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