title: Accessing variables from another classes with setter and getter JAVA
body: <p>This is a very simple example of my project which is a lot more bigger in scale. </p>
  
  <p>Tasks:</p>
  
  <ul>
  <li><p>The password will be set at the setpassword method.</p></li>
  <li><p>The getpassword method will return the password.</p></li>
  <li><p>The password is called at sendmail class  in order to be send via email to the user to log in with the new credentials.</p></li>
  </ul>
  
  <p>But When I run the whole code everything works except that the sendmail class won't access the password from the getpassword method in users class.</p>
  
  <p>I put a simple version of my code:</p>
  
  <p>users class >>>>></p>
  
  <pre><code>public class  users {
  
  
  private String password;
  
  
  public users (){}
  
  // GETTING PASSWORD
  public String getpassword(){
  
      return password;
  }
  
  
  // SETTING PASSWORD
   public void setapassword(String password){
       this.password=password;
   }
  
  
  
  
  }
  </code></pre>
  
  <p>Signup class>>>>>></p>
  
  <pre><code>public class signup {
  
  public void signsup(){
  
      users  user1 =new users();
      user1.setapassword("player"); 
  
      sendmail mail1 =new sendmail();
      mail1.Sendsmail();
  
  }
  }
  </code></pre>
  
  <p>sendmail class>>>></p>
  
  <pre><code>public class sendmail   {
  
  public void  Sendsmail(){
  
      users user1 =new users(); // object
  
      user1.getpassword(); //getting password 
  
   System.out.println(user1.getpassword()); // If print here I get null
   }
   }
  </code></pre>
  
  <p>Main signup Class>>>></p>
  
  <pre><code>public class SignupMain {
  
  public static void main(String[] args) {
  
       signup signup1= new signup();
       signup1.signsup();
     }
  
   }
  </code></pre>