A good answer might be:

if ( args.length != 3 || !args[1].toUpperCase().equals("TO") )
  System.out.println("java CopyBytes source to destination");

Avoid ArrayIndexOutOfBoundsException

The above is the only correct answer, given the choices. The args.length != 3 must come first. If it is true, then the short-circuit OR immediately evaluates to true and there is no danger of trying to look at a non-existent args[1].

If the order were reversed (or if a non-short-circuit OR where used), then the if might throw an ArrayIndexOutOfBoundsException.


Does this code protect the user against accidentally reversing the order of the source and the destination file?