我们知道程序的堆栈在运行时会增长或缩小.在C程序中,当我们使用malloc()分配内存时,如果当前内存不够,它将调用sbrk()扩展堆大小.当我们free()用来释放已分配的内存时,它不会缩小堆.为什么收缩堆没有意义?
class OverloadingVarargs2 {
static void f(float i, Character... args) {
System.out.println("first");
System.out.println(i);
}
static void f(Character... args) {
System.out.println("second");
}
static void test() {
f(1, 'a');
f('b', 'c'); // the method f is ambiguous
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码无法编译,编译器说f是不明确的.但我认为第二种方法可以匹配f('b', 'c');问题是什么?