2017-09-14 46 views
-1
List<myJavaClass> smallListnew = (List<myJavaClass>) i1.next(); 

上面的代码行导致错误,表示对象不能被键入以输入List<myJavaClass>无法将对象转换为列表例外

下面是一些描述码:

List<myJavaClass> i1=bigList.iterator(); 

大名单包含以下方式很多小清单:

//here unique list contains some Long values without the duplicates that were being compared with the refreshJobCountList. 
Iterator<Long> i=uniqueRefJobId.iterator(); 
while (i.hasNext()) { 
    Long refreshJobID = i.next(); 
    List<myJavaClass> smallList = new ArrayList<>(); 

    for (myJavaClass details : refreshJobCountList) { 
     if (refreshJobID.equals(details.getRefreshJobId())) { 
      myJavaClass new_obj=new myJavaClass(); 
      new_obj.setCount(details.getCount()); 
      new_obj.setJobRunId(details.getJobRunId()); 
      new_obj.setRefreshJobId(details.getRefreshJobId()); 
      smallList.add(new_obj); 
     } 
    } 

    bigList.addAll(smallList); 
} 
+0

请提供解决方案,如果有任何疑问关于理解这个请问? – swati

+0

'i1'是什么类型? –

+0

而不是类型转换,你可以将小列表的元素添加到大列表中? '.addAll'会起作用吗? –

回答

0

相反的类型转换的阵列。将小列表的元素添加到更大的列表中。使用.allAll()添加整个列表。