title: Passing username/password from a class and method to another class
body: <p>I have to classes, and I need to input two values into one of the classes in my program.</p>
  
  <pre><code>import java.io.IOException;
  import java.sql.*;
  import static java.lang.System.out;
  
  public class login{
  
      private String username;
      private String password;
  
      public void logon() throws IOException {
  
          System.out.println("Write your Name");
          username = System.console().readLine();
          System.out.println(username);
          System.out.println("Write your Password");
          password = System.console().readLine();
          System.out.println(password);
  
          try {
              // Does stuff
          }
          catch (ClassNotFoundException | SQLException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>Mainly after username and password have been verified in the try catch. I need to transfer those two strings to another class. Seen Below.</p>
  
  <pre><code>    public class ClientHandler {
      protected Socket client;
      protected PrintWriter out;
      protected String Username;
      protected String Password;
  
      public ClientHandler(Socket client) {
         //Does Stuff
      }
  }
  </code></pre>
  
  <p>I would like some pointers to how I can achieve this, either through constructors, or any other method that would be efficient.</p>