title: The string "For input string: "-l" executed and outputted even though it doesn't exist in the code (java threads)
body: <p>The purpose of this program is sending text messages (UTF-8 strings) from a server to a client and vice versa just like two people would text each other on a phone (one phone being the client, one phone being the server)</p>
  
  <p>In the screenshot below, there is an output that says "For input string: "-l" that doesn't actually exist in the code. </p>
  
  <p><a href="https://i.stack.imgur.com/Tn4vq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tn4vq.png" alt="enter image description here"></a></p>
  
  <p>There are three files, one has the main function, one is the server, one is the client.</p>
  
  <p>The command line argument "-l", if present, will run the server thread / server file.</p>
  
  <p>If "-l" is not present, it will run the client thread / client file.</p>
  
  <p>DirectMessengerCombined.java code (main function file):</p>
  
  <pre><code>public class DirectMessengerCombined
  {
  
      public static void main(String[] args)
      {
          DirectMessengerClient Client1 = new DirectMessengerClient();
          DirectMessengerServer Server1 = new DirectMessengerServer();
            for (int i = 0; i &lt; args.length; i++)
            {
                  boolean Client = false;
                  boolean Server = false;
                  if(args[0].equals("3000"))
                  {
                      Client1.ClientRun(args);
                  }
              switch (args[0].charAt(0))
                {
                  case '-':
                   if(args[0].equals("-l"))
                   {  
                       Server = true;
                       if(Server==true)
                       {
                           Server1.ServerRun(args);
                       }
                   }
  
                }
              i=args.length + 20;
  
  
  
            } 
      }
  
  }
  </code></pre>
  
  <p>DirectMessengerServer.java Code: </p>
  
  <pre><code>import java.io.*;
  import java.net.*;
  import java.util.*;
  //import static java.nio.charset.StandardCharsets.*;
  public class DirectMessengerServer
  {
      void ServerRun(String[] args)
      {
  
          Thread Server = new Thread () 
          {
                public void run ()
                {   
                      //String address="127.0.0.1";
                      System.out.println("Server thread is now running");
                      try
                      {
                           System.out.println("Try block begins..");
                           int port_number1= Integer.valueOf(args[0]);
                          System.out.println("Port number is: " + port_number1);
                          // listener = new ServerSocket(port_number1);
                        //   SocketAddress addr = new InetSocketAddress(address, port_number1);
                           System.out.println("Listening for connections..");
                           System.out.println( "Listening on port: " + ( port_number1 ) );
                        //   client_socket= server_socket.accept();
                       //    BufferedReader reader= new BufferedReader(new InputStreamReader(client_socket.getInputStream(), "UTF8"));
                        //   PrintWriter output= new PrintWriter( client_socket.getOutputStream(), true );
                        //   outputstream = new DataOutputStream(smtpSocket.getOutputStream());
                        //   inputstream = new DataInputStream(smtpSocket.getInputStream());
                        //   String input_line= reader.readLine();
                           System.out.println( "Received from client: " );
                         //  System.out.println( input_line );
                        //   output.println( input_line );
                              }
                              catch ( Exception e )
                              {
                                  System.out.println( e.getMessage() );
                              }  
                          }
          };
          Server.start();
      }
  }
  </code></pre>
  
  <p>DirectMessengerClient.java code:</p>
  
  <pre><code>import java.io.*;
  import java.net.*;
  import java.util.*;
  import static java.nio.charset.StandardCharsets.*;
  public class DirectMessengerClient
  {
      //static String[] arguments;
      //public static void main(String[] args)
      //{
      //  arguments = args;
      //}
      public DirectMessengerClient()
      {
  
          //System.out.println("test.");
  
      }
      public void ClientRun(String[] args)
      {
          Thread Client = new Thread ()
          {
            public void run()
            {   
                  System.out.println("Client thread is now running");
                //  String address="127.0.0.1";
                //  ServerSocket server_socket = null;
                //  Socket client_socket = null;
                  //Socket smtpSocket = null;  
                  DataOutputStream outputstream;
                  DataInputStream inputstream;
                  try
                  {
                              System.out.println("Try block begins..");
                              int port_number1= Integer.valueOf(args[0]);
                              System.out.println("Port number is: " + port_number1);
                             // listener = new ServerSocket(port_number1);
                           //   SocketAddress addr = new InetSocketAddress(address, port_number1);
                              System.out.println("Listening for connections..");
                              System.out.println( "Listening on port: " + Integer.toString( port_number1 ) );
                           //   client_socket= server_socket.accept();
                          //    BufferedReader reader= new BufferedReader(new InputStreamReader(client_socket.getInputStream(), "UTF8"));
                           //   PrintWriter output= new PrintWriter( client_socket.getOutputStream(), true );
                           //   outputstream = new DataOutputStream(smtpSocket.getOutputStream());
                           //   inputstream = new DataInputStream(smtpSocket.getInputStream());
                           //   String input_line= reader.readLine();
                              System.out.println( "Received from client: " );
                            //  System.out.println( input_line );
                           //   output.println( input_line );
                  }
                  catch ( Exception e )
                  {
                              System.out.println( e.getMessage() );
                  }
  
            }
          };
  
      Client.start(); 
      }
  }
  </code></pre>
  
  <p>My question is: how is the output "for input string "-l" being outputted when it doesn't actually exist in the code?</p>