Java array class parameter

Java array class parameter

The Array class provides static methods to dynamically create and access Java arrays. Array permits widening conversions to occur during a get or set operation, but throws an IllegalArgumentException if a narrowing conversion would occur.

Method Summary

Sets the value of the indexed component of the specified array object to the specified boolean value.

Methods inherited from class java.lang.Object

Method Detail

newInstance

public static Object newInstance(Class componentType, int length) throws NegativeArraySizeException

Creates a new array with the specified component type and length. Invoking this method is equivalent to creating an array as follows:

int[] x = ; Array.newInstance(componentType, x);

newInstance

public static Object newInstance(Class componentType, int. dimensions) throws IllegalArgumentException, NegativeArraySizeException

Creates a new array with the specified component type and dimensions. If componentType represents a non-array class or interface, the new array has dimensions.length dimensions and componentType as its component type. If componentType represents an array class, the number of dimensions of the new array is equal to the sum of dimensions.length and the number of dimensions of componentType . In this case, the component type of the new array is the component type of componentType . The number of dimensions of the new array must not exceed 255.

getLength

public static int getLength(Object array) throws IllegalArgumentException

get

public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Returns the value of the indexed component in the specified array object. The value is automatically wrapped in an object if it has a primitive type.

Читайте также:  Python float без нулей

getBoolean

public static boolean getBoolean(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

getByte

public static byte getByte(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

getChar

public static char getChar(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

getShort

public static short getShort(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

getInt

public static int getInt(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

getLong

public static long getLong(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

getFloat

public static float getFloat(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

getDouble

public static double getDouble(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

set

public static void set(Object array, int index, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified new value. The new value is first automatically unwrapped if the array has a primitive component type.

setBoolean

public static void setBoolean(Object array, int index, boolean z) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Sets the value of the indexed component of the specified array object to the specified boolean value.

setByte

public static void setByte(Object array, int index, byte b) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

setChar

public static void setChar(Object array, int index, char c) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

setShort

public static void setShort(Object array, int index, short s) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

setInt

public static void setInt(Object array, int index, int i) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

setLong

public static void setLong(Object array, int index, long l) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

setFloat

public static void setFloat(Object array, int index, float f) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

setDouble

public static void setDouble(Object array, int index, double d) throws IllegalArgumentException, ArrayIndexOutOfBoundsException

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Читайте также:  Loading third party javascript

Источник

Оцените статью