commandwords.java
来自「现在在国外大学里最流行的java学习软件,同时还有大量的example,在名为p」· Java 代码 · 共 50 行
JAVA
50 行
/** * This class holds an enumeration of all command words known * to the program. * * @author Michael Kolling and David J. Barnes * @version 2006.03.30 */public class CommandWords{ // a constant array that holds all valid command words private static final String validCommands[] = { "add", "get", "search", "list", "remove", "help", "quit", }; /** * Constructor for CommandWords */ public CommandWords() { } /** * Check whether a given String is a valid command word. * @param aString The string to be checked. * @return true if it is valid, false if it isn't. */ public boolean isCommand(String aString) { if(aString != null){ for(int i = 0; i < validCommands.length; i++) { if(validCommands[i].equals(aString)) return true; } } // if we get here, the string was not found in the commands return false; } /** * Print all valid commands to System.out. */ public void showAll() { for(String command : validCommands) { System.out.print(command + " "); } System.out.println(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?