Class ArrayUtil

  • Direct Known Subclasses:
    U.A

    public class ArrayUtil
    extends java.lang.Object
    数组帮助类
    Author:
    WD
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <E> E[] add​(E[] one, int onePos, int oneLength, E[] two, int twoPos, int twoLength)
      数组相加
      static <E> E[] add​(E[] one, E[] two)
      数组相加
      static <E> E[] add​(E[] one, E[] two, int twoLength)
      数组相加
      static java.lang.Object array​(java.lang.String s, java.lang.Class<?> c)
      根据传入的字符串转换成字符数组
      static java.lang.Object array​(java.lang.String s, java.lang.String sepa, java.lang.Class<?> c)
      根据传入的字符串转换成字符数组
      static <E> void copy​(E[] src, int srcPos, E[] dest, int destPos, int length)
      拷贝数组
      static <E> void copy​(E[] src, E[] dest)
      拷贝数组 已dest长度为准
      static <E> void copy​(E[] src, E[] dest, int pos)
      拷贝数组 已dest长度为准
      static <E> E[] getArray​(E... e)
      获得数组
      static <E> E[] getArray​(java.lang.Class<E> clazz, int length)
      获得数据
      static boolean isArray​(java.lang.Object obj)
      判断是否数组
      static int[] toInt​(java.lang.Integer[] n)
      把Integer数组转换成int数组
      static java.lang.Integer[] toInteger​(int[] n)
      把int数组包装成Integer数组
      static java.lang.Integer[] toInteger​(java.lang.String[] s)
      把String数组包装成Integer数组
      static <E> java.util.List<E> toList​(E... e)
      把数组转换成列表
      static java.lang.String toString​(java.lang.Object[] a)
      把数组对象转换成字符串
      static java.lang.String[] toStringArray​(java.io.Serializable[] a)
      把数组对象转换成字符串
      static java.lang.String[] toStringArray​(java.lang.Integer[] n)
      把Integer数组转换成String数组
      static java.lang.String[] toStringArray​(java.lang.Object[] a)
      把数组对象转换成字符串
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArrayUtil

        public ArrayUtil()
    • Method Detail

      • array

        public static java.lang.Object array​(java.lang.String s,
                                             java.lang.Class<?> c)
        根据传入的字符串转换成字符数组
        Parameters:
        s - 字符串
        c - 要转换的类型
        Returns:
        字符数组
      • array

        public static java.lang.Object array​(java.lang.String s,
                                             java.lang.String sepa,
                                             java.lang.Class<?> c)
        根据传入的字符串转换成字符数组
        Parameters:
        s - 字符串
        sepa - 分隔符
        c - 要转换的类型
        Returns:
        字符数组
      • isArray

        public static boolean isArray​(java.lang.Object obj)
        判断是否数组
        Parameters:
        obj - 对象
        Returns:
        是否数组
      • toList

        @SafeVarargs
        public static <E> java.util.List<E> toList​(E... e)
        把数组转换成列表
        Type Parameters:
        E - 泛型
        Parameters:
        e - 元素数组
        Returns:
        元素列表
      • copy

        public static <E> void copy​(E[] src,
                                    E[] dest)
        拷贝数组 已dest长度为准
        Type Parameters:
        E - 泛型
        Parameters:
        src - 原数组
        dest - 目标数组
      • copy

        public static <E> void copy​(E[] src,
                                    E[] dest,
                                    int pos)
        拷贝数组 已dest长度为准
        Type Parameters:
        E - 泛型
        Parameters:
        src - 原数组
        dest - 目标数组
        pos - 从第几位开始
      • copy

        public static <E> void copy​(E[] src,
                                    int srcPos,
                                    E[] dest,
                                    int destPos,
                                    int length)
        拷贝数组
        Type Parameters:
        E - 泛型
        Parameters:
        src - 原数组
        srcPos - 从原数组第几位开始
        dest - 目标数组
        destPos - 从目标组第几位开始
        length - 拷贝长度
      • toInteger

        public static java.lang.Integer[] toInteger​(int[] n)
        把int数组包装成Integer数组
        Parameters:
        n - int数组
        Returns:
        Integer数组
      • toInteger

        public static java.lang.Integer[] toInteger​(java.lang.String[] s)
        把String数组包装成Integer数组
        Parameters:
        s - String数组
        Returns:
        Integer数组
      • toInt

        public static int[] toInt​(java.lang.Integer[] n)
        把Integer数组转换成int数组
        Parameters:
        n - Integer数组
        Returns:
        int数组
      • toStringArray

        public static java.lang.String[] toStringArray​(java.lang.Integer[] n)
        把Integer数组转换成String数组
        Parameters:
        n - Integer数组
        Returns:
        String数组
      • toStringArray

        public static java.lang.String[] toStringArray​(java.io.Serializable[] a)
        把数组对象转换成字符串
        Parameters:
        a - 对象数组
        Returns:
        字符串
      • toStringArray

        public static java.lang.String[] toStringArray​(java.lang.Object[] a)
        把数组对象转换成字符串
        Parameters:
        a - 对象数组
        Returns:
        字符串
      • toString

        public static java.lang.String toString​(java.lang.Object[] a)
        把数组对象转换成字符串
        Parameters:
        a - 对象数组
        Returns:
        字符串
      • add

        public static <E> E[] add​(E[] one,
                                  E[] two)
        数组相加
        Type Parameters:
        E - 泛型
        Parameters:
        one - 第一个数组因数
        two - 第二个数组因数
        Returns:
        相加后的数组
      • add

        public static <E> E[] add​(E[] one,
                                  E[] two,
                                  int twoLength)
        数组相加
        Type Parameters:
        E - 泛型
        Parameters:
        one - 第一个数组因数
        two - 第二个数组因数
        twoLength - 第二个数组长度 一共相加多少长度
        Returns:
        相加后的数组
      • add

        public static <E> E[] add​(E[] one,
                                  int onePos,
                                  int oneLength,
                                  E[] two,
                                  int twoPos,
                                  int twoLength)
        数组相加
        Type Parameters:
        E - 泛型
        Parameters:
        one - 第一个数组因数
        onePos - 第一个数组偏移 从第几个元素开始
        oneLength - 第一个数组长度 一共相加多少长度
        two - 第二个数组因数
        twoPos - 第二个数组偏移 从第几个元素开始
        twoLength - 第二个数组长度 一共相加多少长度
        Returns:
        相加后的数组
      • getArray

        public static <E> E[] getArray​(java.lang.Class<E> clazz,
                                       int length)
        获得数据
        Type Parameters:
        E - 泛型
        Parameters:
        clazz - 数组类型
        length - 数组长度
        Returns:
        数组
      • getArray

        @SafeVarargs
        public static <E> E[] getArray​(E... e)
        获得数组
        Type Parameters:
        E - 泛型
        Parameters:
        e - 要组成数据的参数
        Returns:
        e数组