【问题标题】:Strange Error launch Java (Eclypse)奇怪的错误启动 Java (Eclypse)
【发布时间】:2012-12-11 20:13:18
【问题描述】:

我阅读了有关此问题的讨论,但找不到解决方案!

我写了一个非常简单的程序,但是当我启动它时,出现了这个错误:

           << Selection does not contain a main type >>

非常感谢您提前为我提供帮助。我是 Java 新手:/


public class Implementation{

  public static void Main(String args[]){

    Operations_numbers operations;
    operations = new Operations_numbers();

    int subtraction = operations.subtraction(10,2);
    String result_Comparison = new String();
    result_Comparison = operations.comparison(8,3);

    System.out.println(result_Comparison); 
    System.out.println(subtraction); 

  }

}
---------------
public class Operations_numbers{

  public int subtraction (int x, int y){
    int subtraction;
    subtraction=x-y; 
    return subtraction;
  }

  public String comparison (int x, int y){    
    if(x>y){    
      String result="the number" + x + "is bigger than the number" + y;
      return result;
    }    
    else{  
      String result="the number" + y + "is bigger than the numbero" + x;
      return result;
    }
  }

}

【问题讨论】:

    标签: java launch


    【解决方案1】:

    main 应为小写。正确的签名是

    public static void main(String args[])
    

    【讨论】:

    • 非常感谢你们所有人!你非常非常快!!!现在我为我的问题感到羞耻,这是一个非常小而愚蠢的细节。希望以后我也能成为一名优秀的程序员时能给你一些帮助!安德里亚
    【解决方案2】:

    函数名称区分大小写。正如错误消息所示,它找不到主要功能。但是,您定义了一个 Main 函数。用小写的 main 试试。 :)

    【讨论】:

    • 非常感谢你们所有人!你非常非常快!!!现在我为我的问题感到羞耻,这是一个非常小的和愚蠢的细节。希望以后我也能成为一名优秀的程序员时能给你一些帮助!安德里亚
    【解决方案3】:

    你必须改变

    public static void Main(String args[]) {/* code */}
    

    public static void main(String args[]) { /* code */ }
    

    因为 java 是区分大小写的,并且需要一个名为 main 的方法,以小写形式作为入口点。

    【讨论】:

    • 非常感谢你们所有人!你非常非常快!!!现在我为我的问题感到羞耻,这是一个非常小的和愚蠢的细节。希望以后我也能成为一名优秀的程序员时能给你一些帮助!安德里亚
    猜你喜欢
    • 2013-01-05
    • 2012-08-08
    • 2014-11-11
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-03
    相关资源
    最近更新 更多