question: public static Map parseCommandLineArguments ( String [ ] args ) { Map < String , String > result = new HashMap < String , String > ( ) ; String key , value ; for ( int i = 0 ; i < args . length ; i ++ ) { key = args [ i ] ; if ( key . charAt ( 0 ) == '-' ) { if ( i + 1 < args . length ) { value = args [ i + 1 ] ; if ( value . charAt ( 0 ) != '-' ) { result . put ( key , value ) ; i ++ ; } else { result . put ( key , null ) ; } } else { result . put ( key , null ) ; } } } return result ; }
target:  A simpler form of command line argument parsing. Dan thinks this is highly superior to the overly complexified code that comes before it. Parses command line arguments into a Map. Arguments of the form -flag1 arg1 -flag2 -flag3 arg3 will be parsed so that the flag is a key in the Map (including the hyphen) and the optional argument will be its value (if present).