I am coding a server-client java program. The code was supposed to be running on command prompt
after server run of java server as:
Client user
Where client
is the name of the user which will be passed to args[0]
. In order to take care of the situation where user did not pass the username, I want to initiate a name as anonymous. But the following code did not work and keeps giving ArrayIndexOutOfBoundException
error.
if(args == null || args.length == 0)
{
args[0] = "anonymous";
}
Any suggestion?