gpt4 book ai didi

java - 线程 "main"java.lang.Error : Unresolved compilation (PhraseOMatic) 中出现异常

转载 作者:行者123 更新时间:2023-11-30 04:41:47 25 4
gpt4 key购买 nike

我尝试从 Head First Java 运行代码,如下所示:

public class PhraseOMatic {
public static void main(String[] args){

String[] wordListOne = {"24/7", "mult-iTier", "30,000 foot", "B-to-B", "win-win", "front-end", "web-based", "pervasive", "smart", "six-sigma", "critical-path", "dynamic"};

String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", "distributed", "clustered", "branded", "outside-the-box", "positioned", "networked", "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};

String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "cor competency", "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};

int oneLength = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length;

int rand1 = (int) (Math.random() * oneLength);
int rand2 = (int) (Math.random() * twoLength);
int rand3 = (int) (Math.random() * twoLength);

String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];

System.out.println("What we need is a " + phrase);
}
}

我就是在这里收到此错误:

线程“main”java.lang.Error中出现异常: Unresolved 编译问题:

at PhraseOMatic.main(apples.java:2)

我从错误中看到问题出在第 2 行,但我可以识别错误

最佳答案

查看异常跟踪 (PhraseOMatic.main(apples.java:2))。您的公共(public)类 PhraseOMatic 必须与 PhraseOMatic.java 文件一起保存。 顶级公共(public)类和.java文件的名称必须相同。

关于java - 线程 "main"java.lang.Error : Unresolved compilation (PhraseOMatic) 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12136345/

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