当前位置:网站首页>HashSet转数组
HashSet转数组
2022-07-24 05:27:00 【cxcaln】
开发过程中,我们经常将数据放到集合中进行操作,因为java集合给我们提供了大量的方法函数使用,大大减少了我们的开发工作量。但是有时候我们需要的却是基础数据类型,比如数组,此时我们将集合类型转成数组。虽然集合类有个toArray()方法,但是返回的是Object[]类型,通常情况下我们可以考虑使用stream流进行转,参考代码如下:
HashSet<Integer> set = new HashSet();
int[] a = set.stream().mapToInt(Integer::intValue).toArray()
边栏推荐
猜你喜欢
随机推荐
Jmeter分布式压测
Today, let's talk about the underlying architecture design of MySQL database. How much do you know?
Solution of forgetting root password in mysql5.7 under Windows
sojson jsjiami.com.v6 爬虫js逆向
这些坑你不掌握,你还真不敢用BigDecimal
Windows下Mysql5.7忘记root密码解决方法
CentOS operating system security reinforcement
Several common problems of SQL server synchronization database without public IP across network segments
LM393 voltage comparator and its typical circuit introduction
Summary browser object
利用sshpass批量实现基于key验证
adb交互-干掉难看的默认shell界面
Take you to understand the inventory deduction principle of MySQL database
Grid layout
Yiwen node installation, download and configuration
【LVGL(2)】LVGL入门,在CodeBlock上进行模拟以及移植STM32
Crud of MySQL
【LVGL(3)】设置对象大小、位置、盒子模型、状态
sql server 同步数据库 跨网段无公网ip几个常见小问题问题
分组后返回每组中的最后一条记录 GROUP_CONCAT用法









