这是我的计划.我不知道为什么我会收到编译时错误.
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String[] args) {
List< ? extends Number > list = new ArrayList<Integer>();
list.add(6); // Compile Time Error
System.out.println(list);
}
}
Run Code Online (Sandbox Code Playgroud)
但是以下程序运行正常
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String[] args) {
List< ? super Number > list = new ArrayList<Number>();
list.add(6);
System.out.println(list);
}
}
Run Code Online (Sandbox Code Playgroud)
Eclipse出错:
以下是Eclipse的错误描述:
类型List中的方法add(int,capture#1-of?extends Number)不适用于参数(int)
union u{
char ch[41];
int b[10];
}un;
Run Code Online (Sandbox Code Playgroud)
LLVM编译到此
%union.u = type { [10 x i32], [4 x i8] }
Run Code Online (Sandbox Code Playgroud)
还有这个
union un{
struct s{
int a;
float f;
double d;
}st;
int intArr[10];
}uno;
Run Code Online (Sandbox Code Playgroud)
编译到这
%union.un = type { %struct.s, [24 x i8] }
%struct.s = type { i32, float, double }
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释联合类型是如何派生出来的吗?
为什么这个程序的输出是10,为什么不是11?
public class Test {
public static void main(String[] args){
int p = 10;
p = p++;
System.out.println(p);
}
}
Run Code Online (Sandbox Code Playgroud)