¿¹Á¦

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$
}