Java编译错误:List <integer>无法转换为ArrayList <integer>

时间:2018-07-19 19:12:04

标签: java list arraylist

程序类似于:

p.dsp(bl);

错误消息:

  

不兼容的类型:列表不能转换为ArrayList   在-n

如何解决该错误?

2 个答案:

答案 0 :(得分:4)

并非每个Function tableau() Dim fld As PivotField Dim pitem As PivotItem Dim i As Long Dim arr() As Variant Sheets("PivotTableSheet").Activate For Each fld In Sheets("PivotTableSheet").PivotTables("PivotTable").PivotFields If fld.Orientation <> xlHidden And fld.Orientation = xlColumnField Then 'loop through filtered pivot fields i = 1 For Each pitem In fld.PivotItems 'loop through visible items in filtered pivot fields If pitem.Visible = True Then ReDim arr(1 To i) As Variant arr(i) = pitem Sheets("Données").ListObjects("table1").Range.AutoFilter Field:=TRVFILTRE(fld.Name), Criteria1:=arr, Operator:=xlFilterValues i = i + 1 End If Next pitem End If Next fld End Function 都是List<Integer>ArrayList<Integer>方法接受dsp,因此要使其起作用,您将传递类型ArrayList<Integer>或将方法更改为接受ArrayList<Integer>

此外,利用泛型,我将使用List<Integer>而不是List<Integer>作为返回类型。

答案 1 :(得分:0)

您不能从父级转换为子级,您的dsp方法应接受List而不是ArrayList