2014-09-27 93 views
0

这里是我的代码:没有ARG方法编译器错误

public class XYZ { 

    public static void overLoaded(Object a) { 
     System.out.println("IN OBJECT"); 
    } 

    public static void main(String[] args) { 
     overLoaded(); 
    } 
} 

我预计编译时错误,因为没有ARG方法,而是输出出来是在对象

请解释输出。

+3

你的代码不会编译。如果你认为它编译你做错了什么。 – 2014-09-27 13:42:30

+0

http://ideone.com/o7sugO打印错误消息'Main.java:16:error:方法overLoaded在类Ideone中不能应用于给定的类型; overLoaded();' – 2014-09-27 13:43:41

+1

让我猜测,您已将类更改为您发布的代码,但运行的是旧版本? – Holger 2014-09-27 14:12:55

回答

5

我只是想你的代码,我得到:

method overLoaded in class XYZ cannot be applied to given types; 
overLoaded(); 
^ 
    required: Object 
    found: no arguments 
    reason: actual and formal argument lists differ in length 

1 error 

所以,如果你是你所描述的行为,无论是你的编译器被严重损坏,或者您提供给我们的代码是不你有代码。