我尝试从 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 中的异常:未解决的编译问题:
at PhraseOMatic.main(apples.java:2)
我从错误中看到问题出在第 2 行,但我可以识别错误