在chrome developer工具中,我们可以使用"store as global variable"将对象值保存到变量中.但我得到的错误如下."无法保存到临时变量."

我问了很多与此相关的问题,但无法解决我的问题。
这是我的问题。
我有一个父抽象类。
public abstract class Parent{ }
Run Code Online (Sandbox Code Playgroud)
我还有另外两个子类,它们是从上面的父类扩展而来的。
public class ChildOne extends Parent{}
public class ChildTwo extends Parent{}
Run Code Online (Sandbox Code Playgroud)
在另一堂课中,我使用这三个课程,如下所示。
public class A{
public List<ExcelRecord<Parent>> getExcelRecords() {
ChildOne childone = new ChildOne();
List<ExcelRecord<ChildOne>> list = new ArrayList<>();
// some logic here
return list; // **compilation here**
}
}
Run Code Online (Sandbox Code Playgroud)
该代码产生以下编译错误:
required: List<ExcelRecord<Parent>>
provided: List<ExcelRecord<ChildOne>>
Run Code Online (Sandbox Code Playgroud)
我需要将子类型泛型返回到父类型泛型。我怎样才能实现这个目标?
请注意,此方法的返回值正在旧代码中使用,无法进行相应更改。它应该保留List<ExcelRecord<Parent>>。
我正在学习 Kotlin,并且我用 Kotlin 编写了以下代码片段。除了使用 if-else 条件之外,还有什么简洁的方法可以编写以下代码吗?
fun test(a: int, b: int): Coding {
return Coding().apply{
if(a>b){
comment = "first value greater than second value"
value = a
}else{
comment = "second value greater than or equal to first value"
value = b
}
}
}
Run Code Online (Sandbox Code Playgroud)