Compare commits
2 Commits
81e72ba458
...
2d1507022e
| Author | SHA1 | Date |
|---|---|---|
|
|
2d1507022e | 4 weeks ago |
|
|
911d0fba4c | 4 weeks ago |
2 changed files with 34 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||||
|
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); // 防御性拷贝,避免外部修改
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue