java - 是否可以使用 int[] 创建 Foo[] ,其中 Foo 使用流将该 int 带入构造函数。爪哇 11
问题描述
基本上我有一个整数数组,我需要将其更改为一个对象数组,该数组接受一个整数作为构造函数。我只是想知道这是否可以在 java 11 中使用流。
解决方案
int input[] = {1, 2, 3, 4, 5};
YourClass[] output = IntStream.of(input)
.mapToObj(YourClass::new)
.toArray(YourClass[]::new);
推荐阅读
- c# - Selenium c# click exacly span 1 by xpath
- java - 如何将加密值从包含“onchange”的 JAVA 构建的 HTML 传递到 HTML
- php - PHP如何从配置目录中获取数据?拉拉维尔
- reactjs - 如何在reactjs的地图功能中连接
- android - 为自定义视图添加了触摸反馈
- wicket - Wicket - MarkupNotFoundException:未找到组件“com.hello.Hello”的“html”类型标记
- visual-studio-2012 - 如何使用 Scaffold-DbContext 在 Visual Studio 2017 中连接 Oracle 数据库
- powershell - 根据用户输入选择使用 OUPath
- docker - 在 docker swarm 中的两个容器之间共享数据
- angular - 如何检查事件目标是否在一个元素内?