Tag: wildcard

List和List 之间的区别

我已经读过很多关于此的内容了,我知道: List listOfObject = new ArrayList(); // (0) //can only work for TYPE == Object. //if TYPE extends Object (and thus objects of type TYPE are Objects), //this is not the same with Lists: List is not a List 现在我已经读过以下内容: List undefinedList = new ArrayList(); // (1) //works for ANY type (except for primitives) 和 […]

创建无界和有界外卡类型数组之间的区别?

为什么这段代码有效 ArrayList[] arr = new ArrayList[2]; 但以下两个不是? ArrayList[] arr = new ArrayList[2]; ArrayList[] arr = new ArrayList[2]; 最后两行生成编译错误; 错误:通用数组创建。 请澄清差异。 更新 另一方面, ArrayList[] arr = new ArrayList[2]; 编译好但是 ArrayList arr = new ArrayList(); 不。

Javagenerics,对象和通配符的差异和说明

我希望理解这个概念: T对象 – 通用,将被删除为实际类型。 ? 对象 – 会被抹去什么? Object对象; T之间有什么区别? 和Object ? 我很容易理解#1,但是怎么样: Object var; ? var; 两者有什么区别? 我看过我不能用? 明确地,像T或任何其他变量,那? 与对象有关,而与类型无关。 但实际原因是什么? 为什么我不能只编写一个对象List ( List )而不是一个通配符List ( List )? 因为我不知道两种情况下的对象类型。 另外,我想知道什么是擦除? ?

java Runtime.getRunTime()。exec&wildcards?

我正试图通过使用删除垃圾文件 Process p = Runtime.getRuntime().exec(); 只要我不使用通配符,它​​工作正常,即这工作: Process p = Runtime.getRuntime().exec(“/bin/rm -f specificJunkFile.java”); 而以下会抛出“没有这样的文件或目录”: Process p = Runtime.getRuntime().exec(“/bin/rm -f *.java”); 我应该能够做到这里概述的所有好事,对吧?