当前位置:网站首页>List set to array
List set to array
2022-06-28 13:05:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
In the collection and array of small problems with each other
One 、 When a collection is converted to an array , Collection provides two methods
1,toArray , but its return value type is Object
During the strong turn, it will report java.lang.ClassCastException Class conversion exception
2,toArray The method with parameters of , When creating an array, specify the length of the array , Best with set size bring into correspondence with , Otherwise, the set length is greater than the array length , The original array Jiangbei is reset to null
Pictured , Specify the array length as the collection length
Pictured , The specified array length is less than the collection length
Two 、 Array to set
Use : Arrays.asList( Array );
asList Back to a Array The inner class of , It has no way of the implementing collections , An error will occur when adding, deleting, and querying the returned set
Pictured :
a1[0] = “toto”;// Modifying the original array will affect the converted set
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/150684.html Link to the original text :https://javaforall.cn
边栏推荐
- Namespace and scope
- You must configure either the server or JDBC driver (via the ‘serverTimezone‘ configuration property
- 无心剑英译朱熹《观书有感二首·其一》
- manjaro easyconnecy报错:libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
- Deep understanding of Bayes theorem
- Mysq 8.0 launched histogram, which greatly improved the performance!
- 在线JSON转PlainText工具
- Arduino-ESP32闪存文件插件程序搭建和上传
- FH511+TP4333组成一个户外移动电源照明野营灯方案。
- The white paper on the panorama of the digital economy and the digitalization of consumer finance were released
猜你喜欢

Vs2012 VC creates a new blank window application

深入理解贝叶斯定理

Scratch travel photo album Electronic Society graphical programming scratch grade examination level 1 true questions and answers analysis June 2022

flink核心之watermarker

Deep understanding of Bayes theorem

From jsonpath and XPath to spl

Mysql database literacy, do you really know what a database is

移动Web实训-flex布局测试题1

在线JSON转PlainText工具

MySQ 8.0 推出直方图,性能大大提升!
随机推荐
pytorch模型调参、训练相关内容
[MySQL from introduction to mastery] [advanced part] (III) creation of MySQL users_ Modification_ Delete and password settings
Here comes Wi Fi 7. How strong is it?
2. 01背包问题
认识启动函数,找到用户入口
PHP抓取网页获取特定信息
数启扬帆,智聚人才 | 腾讯云数据库 & CSDN 工程师能力轻量认证发布会重磅来袭!...
JS class 并不只是简单的语法糖!
弹性盒子自动换行小Demo
FS7022方案系列FS4059A双节两节锂电池串联充电IC和保护IC
Watermaker of the Flink core
Wi-Fi 7 来啦,它到底有多强?
求职简历的书写技巧
Xiaobai's e-commerce business is very important to choose the right mall system!
5A同步整流芯片 20V转12V2A/5V4.5A大电流 24W大功率同步整流芯片 大电流降压IC FS2462
Vscode如何设置自动保存代码
自定义MySQL连接池
scratch旅行相册 电子学会图形化编程scratch等级考试一级真题和答案解析2022年6月
Copying open source for basic software is not advisable. Self reliance is the right way
pytorch基础