gpt4 book ai didi

java - 无法启动 "Hello World"程序

转载 作者:行者123 更新时间:2023-12-01 17:00:40 25 4
gpt4 key购买 nike

我正在向一位名叫“thenewboston”的 YouTube 用户学习 Java。我下载了 eclipse,输入了一个简单的“hello world”代码,现在我想运行/编译该程序。然而,每当我单击“运行”时,它都会向我显示以下消息:

Unable to launch

The selection cannot be launched, and there are no recent launches

代码如下:

class apples{
public static void main (Sting args[]){
System.out.println("Hello youtube!");
}
}

最佳答案

有问题的行是这样的:

public static void main (Sting args[])
// ^-- this type is spelled "String"

修正数据类型中的拼写,您的程序应该可以运行:

public static void main (String args[]) {
System.out.println("Hello youtube!");
}

由于您是新手,这里有两个提示:

  • 请阅读Java Code Conventions关于命名风格:类名应以大写字母 Apples 开头,而不是 apples
  • 没有任何规则,但您应该将括号保留在以下类型:String[] args 而不是 String args[]

关于java - 无法启动 "Hello World"程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27851311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com