刚装了eclipse,想写个Java程序测试一下能不能用,结果一run就出现错误,Debug也是同样的错误,错误内容为:the selection cannot be launched,and there are no recent launches.由于是初学者,对于Java完全不懂,就上网搜索发现说右键项目选择run再选择run as application,发现找不到这个。

以下是代码

1 package test;
2 
3 public class test {
4 
5     static void main(String[] arg)
6     {
7         System.out.println("Hello World");
8     }
9 }

发现需要加一个public在static前,并且String的S必须为大写,并且main一定要拼写正确。改正后的代码如下

package test;

public class test {

    public static void main(String[] arg)
    {
        System.out.println("Hello World");
    }
}

发现可以运行,成功输出结果Hello World

 

2018.09.18

转载于:https://www.cnblogs.com/do-hardworking/p/9669385.html

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐