我的 JAVA 命令行菜单有问题。这就是我所拥有的......我想做的是在评论中。
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)
}