黑马程序员技术交流社区

标题: 同样一个程序为什么命令行上可以运行,eclipse不可以 [打印本页]

作者: 张翼    时间: 2011-11-7 19:12
标题: 同样一个程序为什么命令行上可以运行,eclipse不可以

public class acc
{
   public static void main(String argv[])
   {
          main_get();
   }
   public static void main_get()
   {
        String str="abcdefg";
          
           showresult(str.length());
           showresult(str.charAt(3));
           showresult(str.indexOf('c'));
           showresult(str.indexOf('d', 1));
           showresult(str.indexOf("e"));
   }
   public static void showresult(Object obj)
   {
           System.out.println(obj);   
   }
}
eclipse上还说:The method showresult(Object) in the type acc is not applicable for the arguments (int)
        The method showresult(Object) in the type acc is not applicable for the arguments (int)
谁知道原因?
作者: zhou_411424    时间: 2011-11-7 19:34
我把这个程序拷到MyEclipse当中,运行了一下,一点问题都没有啊
运行结果是
7
d
2
3
4
作者: 宁超    时间: 2011-11-7 19:37
eclipse可以正常运行的,和楼上的结果一模一样。
作者: 张邦庆    时间: 2011-11-7 19:42
那就是你的编译器配置问题了吧,
好像涉及到了类型方面的你可以看看你的版本
作者: 张翼    时间: 2011-11-7 19:43
eclipse还是运行不了
作者: 张翼    时间: 2011-11-7 19:53
其他程序可以运行。
作者: 王赫麟    时间: 2011-11-8 08:49
是不是配置出错了?
作者: 吉许    时间: 2011-11-8 09:06
楼主你在装过Eclipse后重新装过JDK了吧.我也碰到过和你这差不多的情况,是在重装过JDK后Eclipse出的问题,我把相关的配置都重新配了一遍就OK了.
作者: 崔浩    时间: 2011-11-8 13:18
自动装箱和自动拆箱有问题,是1.5以上的版本有的,把Eclipse的jdk版本换了




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2