¿¹Á¦

public static void main( String[] args ) {
if ( args.length > 0 &&
args[ 0 ] != null &&
( args[ 0 ].equals( "input" ) || //$NON-NLS-1$
args[ 0 ].equals( "output" ) || //$NON-NLS-1$
args[ 0 ].equals("verbose") ) ) { //$NON-NLS-1$
System.out.println( "Valid argument" ); //$NON-NLS-1$
}
}

¼Ö·ç¼Ç
°ü·Ã ÀýÀ» ¸Þ¼Òµå·Î ±×·ìÈ­ÇϽʽÿÀ.
  1. °ü·Ã ÀýÀ» ½Äº°ÇϽʽÿÀ.
  2. ¼­·Î ÀÎÁ¢ÇÑ °ü·Ã ÀýÀ» À̵¿ÇϽʽÿÀ.
  3. °¢ Àý ±×·ìÀ» ¼³¸íÇÏ´Â À̸§ÀÌ ÀÖ´Â ¸Þ¼Òµå¸¦ ÀÛ¼ºÇϽʽÿÀ.
  4. °ü·Ã ÀýÀ» ¸ðµÎ »ç¿ëÇÒ ¶§±îÁö ÀÌ·¯ÇÑ ´Ü°è¸¦ ¹Ýº¹ÇϽʽÿÀ.

public static void main( String[] args ) {
if ( hasFirstArgument( args ) &&
isValidArgument( args[ 0 ] ) ) {
System.out.println( "Not valid argument" ); //$NON-NLS-1$
}
}

private static boolean hasFirstArgument( String[] args ) {
return ( args.length > 0 ) && ( args[ 0 ] != null );
}

private static boolean isValidArgument( String s ) {
return s.equals( "input" ) || //$NON-NLS-1$
s.equals( "output" ) || //$NON-NLS-1$
s.equals( "verbose" ); //$NON-NLS-1$
}