How to simply this logic/code?

Posted by Tattat on Stack Overflow See other posts from Stack Overflow or by Tattat
Published on 2010-03-20T10:26:49Z Indexed on 2010/03/20 10:31 UTC
Read the original article Hit count: 384

I want to write an apps that accepts user command. The user command is used in this format:

command -parameter

For example, the app can have "Copy", "Paste", "Delete" command I am thinking the program should work like this :

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
     **/


}

So, it works, but I think it will become more and more complex when I have more command in my program, also, it is different to read. Any ideas to simply the logic?

© Stack Overflow or respective owner

Related posts about code-optimization

Related posts about java