小编Pub*_*nda的帖子

无法在chrome开发人员工具中保存到临时变量

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

chrome开发工具

global-variables google-chrome-devtools

6
推荐指数
1
解决办法
1805
查看次数

构建 firefox 时未找到 pango 包

我正在构建 Firefox 的定制源代码。当我要构建 Firefox 时,出现以下错误“no pango package error”。我该如何解决这个错误。在此输入图像描述

firefox pango

3
推荐指数
1
解决办法
3525
查看次数

在java中将子类型泛型返回给父类型泛型

我问了很多与此相关的问题,但无法解决我的问题。

这是我的问题。

我有一个父抽象类。

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

java generics inheritance

1
推荐指数
1
解决办法
486
查看次数

在 Kotlin 中编写以下代码段的简洁方法是什么

我正在学习 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)

if-statement kotlin

0
推荐指数
1
解决办法
88
查看次数