Array就是陣列,磁盤陣列模式是把幾個磁盤的存儲空間整合起來,形成一個大的單一連續(xù)的存儲空間。NetRAID控制器利用它的SCSI通道可以把多個磁盤組合成一個磁盤陣列。簡單的說,陣列就是由多個磁盤組成,并行工作的磁盤系統(tǒng)。需要注意的是作為熱備用的磁盤是不能添加到陣列中的。
java.lang.reflect
類 Array
java.lang.Object
java.lang.reflect.Array
public final class Arrayextends ObjectArray 類提供了動態(tài)創(chuàng)建和訪問 Java 數(shù)組的方法。
Array 允許在執(zhí)行 get 或 set 操作期間進行擴展轉(zhuǎn)換,但如果發(fā)生收縮轉(zhuǎn)換,則拋出 IllegalArgumentException。
方法摘要
static Object get(Object array, int index)
返回指定數(shù)組對象中索引組件的值。
static boolean getBoolean(Object array, int index)
以 boolean 形式返回指定數(shù)組對象中索引組件的值。
static byte getByte(Object array, int index)
以 byte 形式返回指定數(shù)組對象中索引組件的值。
static char getChar(Object array, int index)
以 char 形式返回指定數(shù)組對象中索引組件的值。
static double getDouble(Object array, int index)
以 double 形式返回指定數(shù)組對象中索引組件的值。
static float getFloat(Object array, int index)
以 float 形式返回指定數(shù)組對象中索引組件的值。
static int getInt(Object array, int index)
以 int 形式返回指定數(shù)組對象中索引組件的值。
static int getLength(Object array)
以 int 形式返回指定數(shù)組對象的長度。
static long getLong(Object array, int index)
以 long 形式返回指定數(shù)組對象中索引組件的值。
static short getShort(Object array, int index)
以 short 形式返回指定數(shù)組對象中索引組件的值。
static Object newInstance(Class<?> componentType, int length)
創(chuàng)建一個具有指定的組件類型和長度的新數(shù)組。
static Object newInstance(Class<?> componentType, int【】 dimensions)
創(chuàng)建一個具有指定的組件類型和維度的新數(shù)組。
static void set(Object array, int index, Object value)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的新值。
static void setBoolean(Object array, int index, boolean z)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的 boolean 值。
static void setByte(Object array, int index, byte b)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的 byte 值。
static void setChar(Object array, int index, char c)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的 char 值。
static void setDouble(Object array, int index, double d)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的 double 值。
static void setFloat(Object array, int index, float f)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的 float 值。
static void setInt(Object array, int index, int i)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的 int 值。
static void setLong(Object array, int index, long l)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的 long 值。
static void setShort(Object array, int index, short s)
將指定數(shù)組對象中索引組件的值設(shè)置為指定的 short 值。
從類 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
方法詳細(xì)信息
newInstance
public static Object newInstance(Class<?> componentType,
int length)
throws NegativeArraySizeException創(chuàng)建一個具有指定的組件類型和長度的新數(shù)組。調(diào)用此方法等效于創(chuàng)建如下數(shù)組:
int【】 x = ;
Array.newInstance(componentType, x);
參數(shù):
componentType - 表示新數(shù)組的組件類型的 Class 對象
length - 新數(shù)組的長度
返回:
新數(shù)組
拋出:
NullPointerException - 如果指定的 componentType 參數(shù)為 null
IllegalArgumentException - 如果 componentType 為 Void.TYPE
NegativeArraySizeException - 如果指定的 length 為負(fù)
--------------------------------------------------------------------------------
newInstance
public static Object newInstance(Class<?> componentType,
int【】 dimensions)
throws IllegalArgumentException,
NegativeArraySizeException創(chuàng)建一個具有指定的組件類型和維度的新數(shù)組。如果 componentType 表示一個非數(shù)組類或接口,則新數(shù)組具有 dimensions.length 維度,并且將 componentType 作為其組件類型。如果 componentType 表示一個數(shù)組類,則新數(shù)組的維數(shù)等于 dimensions.length 和 componentType 的維數(shù)的總和。在這種情況下,新數(shù)組的組件類型為 componentType 的組件類型。
新數(shù)組的維數(shù)不能超過該實現(xiàn)所支持的數(shù)組維數(shù)(通常為 255)。
參數(shù):
componentType - 表示新數(shù)組的組件類型的 Class 對象
dimensions - 表示新數(shù)組維度的 int 類型的數(shù)組
返回:
新數(shù)組
拋出:
NullPointerException - 如果指定的 componentType 參數(shù)為 null
IllegalArgumentException - 如果指定的 dimensions 參數(shù)是一個零維度的數(shù)組,或者如果所請求的維數(shù)超過了該實現(xiàn)所支持的數(shù)組維數(shù)的限制(通常為 225),或者度的數(shù)組,或者如果所請求的維數(shù)超過了該實現(xiàn)所支持的數(shù)組維數(shù)的限制(通常為 225),或者 componentType 為 Void.TYPE。
NegativeArraySizeException - 如果指定的 dimensions 參數(shù)中的任意組件為負(fù)。
--------------------------------------------------------------------------------
getLength
public static int getLength(Object array)
throws IllegalArgumentException以 int 形式返回指定數(shù)組對象的長度。
參數(shù):
array - 數(shù)組
返回:
數(shù)組的長度
拋出:
IllegalArgumentException - 如果對象參數(shù)不是一個數(shù)組
--------------------------------------------------------------------------------
get
public static Object get(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException返回指定數(shù)組對象中索引組件的值。如果該值是一個基本類型值,則自動將其包裝在一個對象中。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的(可能已封裝的)值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
--------------------------------------------------------------------------------
getBoolean
public static boolean getBoolean(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException以 boolean 形式返回指定數(shù)組對象中索引組件的值。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組,或者如果無法通過一個標(biāo)識或擴展轉(zhuǎn)換將索引元素轉(zhuǎn)換為返回類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
get(java.lang.Object, int)
--------------------------------------------------------------------------------
getByte
public static byte getByte(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException以 byte 形式返回指定數(shù)組對象中索引組件的值。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組,或者如果無法通過一個標(biāo)識或擴展轉(zhuǎn)換將索引元素轉(zhuǎn)換為返回類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
get(java.lang.Object, int)
--------------------------------------------------------------------------------
getChar
public static char getChar(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException以 char 形式返回指定數(shù)組對象中索引組件的值。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組,或者如果無法通過一個標(biāo)識或擴展轉(zhuǎn)換將索引元素轉(zhuǎn)換為返回類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
get(java.lang.Object, int)
--------------------------------------------------------------------------------
getShort
public static short getShort(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException以 short 形式返回指定數(shù)組對象中索引組件的值。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組,或者如果無法通過一個標(biāo)識或擴展轉(zhuǎn)換將索引元素轉(zhuǎn)換為返回類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
get(java.lang.Object, int)
--------------------------------------------------------------------------------
getInt
public static int getInt(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException以 int 形式返回指定數(shù)組對象中索引組件的值。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組,或者如果無法通過一個標(biāo)識或擴展轉(zhuǎn)換將索引元素轉(zhuǎn)換為返回類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
get(java.lang.Object, int)
--------------------------------------------------------------------------------
getLong
public static long getLong(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException以 long 形式返回指定數(shù)組對象中索引組件的值。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組,或者如果無法通過一個標(biāo)識或擴展轉(zhuǎn)換將索引元素轉(zhuǎn)換為返回類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
get(java.lang.Object, int)
--------------------------------------------------------------------------------
getFloat
public static float getFloat(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException以 float 形式返回指定數(shù)組對象中索引組件的值。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組,或者如果無法通過一個標(biāo)識或擴展轉(zhuǎn)換將索引元素轉(zhuǎn)換為返回類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
get(java.lang.Object, int)
--------------------------------------------------------------------------------
getDouble
public static double getDouble(Object array,
int index)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException以 double 形式返回指定數(shù)組對象中索引組件的值。
參數(shù):
array - 數(shù)組
index - 索引
返回:
指定數(shù)組中索引組件的值
拋出:
NullPointerException - 如果指定對象為 null
IllegalArgumentException - 如果指定對象不是一個數(shù)組,或者如果無法通過一個標(biāo)識或擴展轉(zhuǎn)換將索引元素轉(zhuǎn)換為返回類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
get(java.lang.Object, int)
--------------------------------------------------------------------------------
set
public static void set(Object array,
int index,
Object value)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的新值。如果數(shù)組的類型為基本組件類型,則新值第一個被自動解包。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
value - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果數(shù)組組件類型是基本類型并且解包轉(zhuǎn)換失敗
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
--------------------------------------------------------------------------------
setBoolean
public static void setBoolean(Object array,
int index,
boolean z)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的 boolean 值。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
z - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果無法通過一個標(biāo)識或基本擴展轉(zhuǎn)換將指定值轉(zhuǎn)換為基礎(chǔ)數(shù)組的指定類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
set(java.lang.Object, int, java.lang.Object)
--------------------------------------------------------------------------------
setByte
public static void setByte(Object array,
int index,
byte b)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的 byte 值。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
b - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果無法通過一個標(biāo)識或基本擴展轉(zhuǎn)換將指定值轉(zhuǎn)換為基礎(chǔ)數(shù)組的指定類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
set(java.lang.Object, int, java.lang.Object)
--------------------------------------------------------------------------------
setChar
public static void setChar(Object array,
int index,
char c)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的 char 值。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
c - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果無法通過一個標(biāo)識或基本擴展轉(zhuǎn)換將指定值轉(zhuǎn)換為基礎(chǔ)數(shù)組的指定類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
set(java.lang.Object, int, java.lang.Object)
--------------------------------------------------------------------------------
setShort
public static void setShort(Object array,
int index,
short s)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的 short 值。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
s - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果無法通過一個標(biāo)識或基本擴展轉(zhuǎn)換將指定值轉(zhuǎn)換為基礎(chǔ)數(shù)組的指定類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
set(java.lang.Object, int, java.lang.Object)
--------------------------------------------------------------------------------
setInt
public static void setInt(Object array,
int index,
int i)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的 int 值。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
i - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果無法通過一個標(biāo)識或基本擴展轉(zhuǎn)換將指定值轉(zhuǎn)換為基礎(chǔ)數(shù)組的指定類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
set(java.lang.Object, int, java.lang.Object)
--------------------------------------------------------------------------------
setLong
public static void setLong(Object array,
int index,
long l)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的 long 值。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
l - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果無法通過一個標(biāo)識或基本擴展轉(zhuǎn)換將指定值轉(zhuǎn)換為基礎(chǔ)數(shù)組的指定類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
set(java.lang.Object, int, java.lang.Object)
--------------------------------------------------------------------------------
setFloat
public static void setFloat(Object array,
int index,
float f)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的 float 值。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
f - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果無法通過一個標(biāo)識或基本擴展轉(zhuǎn)換將指定值轉(zhuǎn)換為基礎(chǔ)數(shù)組的指定類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
set(java.lang.Object, int, java.lang.Object)
--------------------------------------------------------------------------------
setDouble
public static void setDouble(Object array,
int index,
double d)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException將指定數(shù)組對象中索引組件的值設(shè)置為指定的 double 值。
參數(shù):
array - 數(shù)組
index - 數(shù)組內(nèi)部的索引
d - 索引組件的新值
拋出:
NullPointerException - 如果指定對象參數(shù)為 null
IllegalArgumentException - 如果指定對象參數(shù)不是一個數(shù)組,或者如果無法通過一個標(biāo)識或基本擴展轉(zhuǎn)換將指定值轉(zhuǎn)換為基礎(chǔ)數(shù)組的指定類型
ArrayIndexOutOfBoundsException - 如果指定的 index 參數(shù)為負(fù),或者如果它大于或等于指定數(shù)組的長度
另請參見:
set(java.lang.Object, int, java.lang.Object)