嘿我收集器有這個問題。 <? super Object, R>
R值不要發現java stream toCollection ArrayList R找不到
爲例:
Stream stream = DentityList.stream().filter(entity -> entity instanceof EntityLivingBase);
Stream streamMap = stream.<Object>map(entity -> (EntityLivingBase)entity);
Stream stream1 = streamMap.<ArrayList<EntityLivingBase>, Entity>collect((Collectors.<? super Object, R>toCollection((Supplier<R>)ArrayList::new)));
list type = arrayList<EntityLivingBase> (edit)
請幫我沒有得到它!
「R」類定義在哪裏? –
在一個不相關的說明中,爲什麼你要使用原始'Stream'類型(而不是'Stream'?) –
尋求調試幫助的問題(「爲什麼這個代碼不工作?」)必須包含所需的行爲,具體問題或錯誤以及在問題本身中重現問題所需的最短代碼,沒有明確問題陳述的問題對其他讀者沒有用處,請參閱:如何創建[mcve]。 – GhostCat