Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何遍历Java列表数组将对象键值对保存到自己的数组_Java_Arrays_List_Jpa - Fatal编程技术网

如何遍历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

我想看看是否有可能获取对象的Java列表数组,搜索对象的键值对,并将它们保存到自己的数组中

带有对象的数组

代码

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);