因为java里允许调用一个有返回值的方法的时候不必将返回值赋给变量,这样JVM就不知道你调用的是有返回值的还是没返回值的。
举个例子:
class Test{
public static void testMethod(){
}
public static int testMethod(){
}//姑且假设允许吧
public static void main(String[] args){
int i = testMethod();//这个还说的过去 知道是调用哪个
testMethod();//这个就无法判断调用哪个方法了
}
}