Why does it have to set it to args[0] if the argument length is >0
We can only tell that once we take a look at the program written in the book. As far as I can tell, this particular check is just making sure that the 'host' variable name is never null. The program that follows may be dependant on the presence of this variable name and therefore the author has added a check on this variable so that if user hasn't passed in any argument then set the 'host' to 'localhost'.