java - 超类作为列表中的附加类型
问题描述
public abstract class class1 {
int h;
}
public class class2 extends class1{
int y;
}
import java.util.ArrayList;
import java.util.List;
class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
List<class1> test;
test = new ArrayList<class2>();
}
}
我收到以下错误错误:不兼容的类型:ArrayList 无法转换为 List
解决方案
推荐阅读
- tensorflow - tf.profiler 的峰值内存使用量比 nvidia-smi 多得多?
- java - bean xml中的Spring配置方法引用
- java - 使用 OpenId Connect 的多个 Liberty 服务器 SSO
- image-processing - Tensorflow 2.0 sobel_edges 图像格式?
- jmeter - jmeter线程自动减少活动线程数
- python - 从python中的csv数据绘制
- c++ - 模板中的智能指针 c++
- matlab - SVN MATLAB 问题
- fortran - 当'-align'编译选项已经存在时,Fortran'-align array64byte' 是多余的吗?
- android - Android SafeArgs 数组不兼容