You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
449 B

import java.util.ArrayList;
import java.util.List;
public class HistoryCommand {
// 存储所有输入过的命令
private final List<String> commandHistory = new ArrayList<>();
// 添加命令
public void addCommand(String cmd) {
commandHistory.add(cmd);
}
// 获取全部历史
public List<String> getHistory() {
return new ArrayList<>(commandHistory); // 防御性拷贝,避免外部修改
}
}