In my Java course, I was given a multithread server client project to take a look at. I understand most of the project except this part in the client:
public static void main( String args[] )
{
Client application;
if ( args.length == 0 )
application = new Client( "127.0.0.1" );
else
application = new Client( args[ 0 ] );
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
application.runClient();
}
In particular I don't understand the meaning behind the args
checking. Why do we do it? For example if args
is 0
we connect to the localhost
, but what happens in the else is eluding me. I know that args
contains the supplied command-line arguments as an array of String objects, but that doesn't help me much. So any explanation is welcomed :)