【发布时间】:2023-03-21 02:25:01
【问题描述】:
这是我项目的代码。
public class PhraseOMatic {
public static void main(String[] args) {
String[] wordListOne = {"24/7", "multi-Tier", "30,000 foot", "B-to-B",
"win-win", "front-end", "web-based", "pervasive", "smart", "sixsigma”,"};
String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented",
"centric", "distributed", "clustered", "branded", "outsidethebox",
"positioned", "networked", "focused", "leveraged", "aligned", "targeted", "shared”"};
String[] wordListThree = {"process", "tipping-point", "solution",
"architecture", "core competency”",
"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() * threeLength);
String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " +
wordListThree[rand3];
System.out.println("What we need is a " + phrase);
}
}
它主要来自我的一位讲师。但我必须更改一些东西才能让它真正运行。
我的问题是,我什么时候必须导入 java.util.Arrays?即使我使用的是数组,它也无需导入即可运行。那么,这是为什么呢?
【问题讨论】:
-
您在发布的代码中甚至在哪里使用数组?