public static boolean findOption(String name,List<String> args,boolean remove){
  int idx=args.indexOf(name);
  if (idx >= 0) {
    if (remove) {
      args.remove(idx);
    }
    return true;
  }
  return false;
}

public static boolean findOption ( String name , List < String > args , boolean remove ) { int idx = args . indexOf ( name ) ; if ( idx >= 0 ) { if ( remove ) { args . remove ( idx ) ; } return true ; } return false ; }
finds the specified option among the arguments , and removes it if needed .
