why the getter method goes null when i call in another class?

Tags: , , ,

but in the set method on another class when i got the value is exist,, so i have 3 classes the first class is getter setter class , second is the class to fill the set and the last is class to get the method getter,, but it goes null value…

        public class loginAdminn {

        String Username, Password;

        public String getUsername() {
            return Username;

        public void setUsername(String Username) {
            this.Username = Username;

        public String getPassword() {
            return Password;

        public void setPassword(String Password) {
            this.Password = Password;

    // method to fill the set on another class
    public void in(){
              loginAdminn p = new loginAdminn();
               String user = Username.getText();
               String pass = Password.getPassword().toString();

              // new NewMain().run();

// class method getter (null)

public void jalankan() {

       loginAdminn br = new loginAdminn();

      String kueri = "Select Username, password from Admin";

        int x = 0;

        try {
            ps = conn.prepareStatement(kueri);
            ResultSet rs = ps.executeQuery();

            while (rs.next()) {

                if (br.getUsername().equalsIgnoreCase(rs.getString("Username"))) {
                    if (br.getPassword().equalsIgnoreCase(rs.getString("Password"))) {
                        JOptionPane.showMessageDialog(null, "Masuk Berhasil");
                        x = 1;

            if (x == 1) {
                HomeAdmin b = new HomeAdmin();

            } else {
                JOptionPane.showMessageDialog(null, "Masuk Gagal");

                DaftarAplikasi da = new DaftarAplikasi();


        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

//the getUsername and getPassword goes null


Class A

String  x;

setter getter x

A c = new A();   
c.get...    // object Class A type X

Class B

A c = new A();  
c.get...    // object Class B type X

c.get from Class A   !=   c.get from Class B

Basically by using new you’re creating two independent from each other objects!

Source: stackoverflow