ArrayList.toArray如何返回指定类型的数组
如果不带参数使用ArrayList.toArray,只能返回Object[]。
我想要的是整形数组,如何实现呢。
JDK 1.5的帮助文档如下,我看了还是不知道如何用。
<T> T[] toArray(T[] a)
Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array. Obeys the general contract of the Collection.toArray(Object[]) method.
Specified by:
toArray in interface Collection<E>
Parameters:
a - the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of this list.
Throws:
ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this list.
NullPointerException - if the specified array is null.
我想要的是整形数组,如何实现呢。
JDK 1.5的帮助文档如下,我看了还是不知道如何用。
<T> T[] toArray(T[] a)
Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array. Obeys the general contract of the Collection.toArray(Object[]) method.
Specified by:
toArray in interface Collection<E>
Parameters:
a - the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of this list.
Throws:
ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this list.
NullPointerException - if the specified array is null.
...全文
相关推荐
RSA分段加密前端实践
RSA分段加密前端实践
微信小程序 wx.request 和 wx.uploadFile请求/上传封装,JSEncrypt加密字符串超长采用分段加密
微信小程序 wx.request 和 wx.uploadFile请求/上传封装,JSEncrypt加密字符串超长采用分段加密封装encryptUnicodeLong()
前端 RSA分段加密算法
RSA非对称加密,前端加解密算法代码。公钥明文,私钥各自保存,公钥加密,私钥解密。 RSA分段加密 适用于加密长度超标,可用于图片base64等大长度内容加密。
JSEncrypt 前端js分段加密解密RSA
jsencrypt.min.js通过JSEncrypt分段加密解密,自己添加了分段加解密的方法
微信小程序rsa分段加密
微信小程序rsa分段加密demo。分段加密用encryptLong,不分段用encrypt


Java SE
