Array类的所有方法解析

在 Java 中,java.lang.Array 类包含了用于操作数组的静态方法。以下是 Array 类中所有的方法解析:

  1. public static Object get(Object array, int index): 获取指定数组索引处的元素值。

  2. public static boolean getBoolean(Object array, int index): 获取指定布尔型数组索引处的元素值。

  3. public static byte getByte(Object array, int index): 获取指定字节型数组索引处的元素值。

  4. public static char getChar(Object array, int index): 获取指定字符型数组索引处的元素值。

  5. public static short getShort(Object array, int index): 获取指定短整型数组索引处的元素值。

  6. public static int getInt(Object array, int index): 获取指定整型数组索引处的元素值。

  7. public static long getLong(Object array, int index): 获取指定长整型数组索引处的元素值。

  8. public static float getFloat(Object array, int index): 获取指定单精度浮点型数组索引处的元素值。

  9. public static double getDouble(Object array, int index): 获取指定双精度浮点型数组索引处的元素值。

  10. public static void set(Object array, int index, Object value): 设置指定数组索引处的元素值。

  11. public static void setBoolean(Object array, int index, boolean value): 设置指定布尔型数组索引处的元素值。

  12. public static void setByte(Object array, int index, byte value): 设置指定字节型数组索引处的元素值。

  13. public static void setChar(Object array, int index, char value): 设置指定字符型数组索引处的元素值。

  14. public static void setShort(Object array, int index, short value): 设置指定短整型数组索引处的元素值。

  15. public static void setInt(Object array, int index, int value): 设置指定整型数组索引处的元素值。

  16. public static void setLong(Object array, int index, long value): 设置指定长整型数组索引处的元素值。

  17. public static void setFloat(Object array, int index, float value): 设置指定单精度浮点型数组索引处的元素值。

  18. public static void setDouble(Object array, int index, double value): 设置指定双精度浮点型数组索引处的元素值。

  19. public static int getLength(Object array): 获取指定数组的长度。

  20. public static Object newInstance(Class<?> componentType, int length): 创建一个具有指定类型和长度的新数组。

  21. public static Object newInstance(Class<?> componentType, int... dimensions): 创建一个具有指定类型和维度的新数组。

  22. public static void fill(Object[] a, Object val): 将整个数组或指定范围内的元素填充为指定值。

  23. public static void fill(Object[] a, int fromIndex, int toIndex, Object val): 将数组指定范围内的元素填充为指定值。

  24. public static void sort(Object[] a): 对数组进行排序。

  25. public static void sort(Object[] a, int fromIndex, int toIndex): 对数组指定范围内的元素进行排序。

  26. public static String toString(Object[] a): 以字符串形式返回数组内容。

猜你喜欢

转载自blog.csdn.net/monicateacat/article/details/132856103