【发布时间】:2012-08-01 01:40:28
【问题描述】:
我的 JAVA 命令行菜单有问题。这就是我所拥有的……我想做的是在 cmets 中。
private void listStudents(){
out.println("\n\tStudent Listing");
//Call datastore method that returns all student names as an array of strings
String[] list = data.getStudents();
//Display all names (use foreach statement)
for (String name : list) {
}
}
这是我也坚持使用的数据存储方法......
String[] getStudents() {
return (String[]) students.toArray();
}
// Method to return students who match search term
String[] findStudents(String searchTerms) {
// Use foreach loop to visit each item in students ArrayList,
// and if the name matches the search term, add it to a new ArraList.
// Then return the new ArrayList as a string array (see getStudents)
}
【问题讨论】:
-
欢迎来到 StackOverflow。如果您坚持使用该方法,那么您实际上尝试过哪些不起作用的方法?我们很乐意提供帮助,但这几乎是一种“展示你的作品”类型的网站——当你说某些东西不起作用时,你应该包括哪些东西不起作用。 :-)
-
@KenWhite 谢谢。嗯,我还没有真正尝试过任何事情,我完全不知道该怎么做。谢谢介绍:)