我想寫一個接受用戶命令的應用程序。用戶命令此格式中使用:如何簡化這個邏輯/代碼?
命令-parameter
例如,應用程序可以有「複製」,「粘貼」,「刪除」命令 我想程序應該這樣的工作:
public static void main(String args[]){
if(args[0].equalsIgnoreCase("COPY")){
//handle the copy command
} else if(args[0].equalsIgnoreCase("PASTE")){
//handle the copy command
}/**
code skipped
**/
}
所以,它的工作原理,但我認爲它會變得越來越複雜,當我在我的程序有更多的命令,而且,不同的閱讀。任何想法只是邏輯?
另請參閱http://stackoverflow.com/questions/1199646 – dfa 2010-03-20 10:31:35