如何遍历Java列表数组将对象键值对保存到自己的数组
我想看看是否有可能获取对象的Java列表数组,搜索对象的键值对,并将它们保存到自己的数组中 带有对象的数组 代码如何遍历Java列表数组将对象键值对保存到自己的数组,java,arrays,list,jpa,Java,Arrays,List,Jpa,我想看看是否有可能获取对象的Java列表数组,搜索对象的键值对,并将它们保存到自己的数组中 带有对象的数组 代码 public List findEmailTest(){ int-appId=1; 列表myList= applicationUserSubscriptionRepository.FindUserEmailSubscriptedtoApplication(appId); System.out.println(myList); 假设我想迭代这个数组,并将所有“AppSupporteI
public List findEmailTest(){
int-appId=1;
列表myList=
applicationUserSubscriptionRepository.FindUserEmailSubscriptedtoApplication(appId);
System.out.println(myList);
假设我想迭代这个数组,并将所有“AppSupporteId”保存到它自己的数组中
NewArray[]=myList.AppSupporteId
任何建议或帮助都将不胜感激,谢谢!如果您使用的对象具有以下字段,则可以尝试此操作
myList.stream()
.map(userSub -> userSub.getApplicationsSupported())
.map(app -> app.getAppSupportedId())
.toArray(Integer[] :: new);
如果它是一个映射
,那么您可以尝试
myList.stream()
.map(userSub -> userSub.get("applicationsSupported"))
.map(app -> app.get("appSupportedId"))
.toArray(Integer[] :: new);
myList.stream()
.map(userSub -> userSub.getApplicationsSupported())
.map(app -> app.getAppSupportedId())
.toArray(Integer[] :: new);
myList.stream()
.map(userSub -> userSub.get("applicationsSupported"))
.map(app -> app.get("appSupportedId"))
.toArray(Integer[] :: new);