title: getting default values of variables during run time in java
body: <p>When i run this program in Eclipse, I get the default values of the variables and not the values which i enter during runtime. When I run the program, I get the default values of the variables which has been assigned in the constructor <code>public account()</code>, and not those values which I am entering during the runtime. Could someone please explain the reason why this is happening.</p>
  
  <p>Here is my code...</p>
  
  <pre><code>public class bank {
      public static void main(String[] args){
          account[] obj=new account[3]; 
  
          for(int i=0;i&lt;3;i++){
              obj[i]=new account();
              obj[i].entry();
              obj[i].display();
          }
  
          for(int i=0;i&lt;3;i++){
              obj[i]=new account();
              String res=obj[i].getCustomer_name();
              JOptionPane.showMessageDialog(null, res);
          }
  
          account obj=new account();
          obj.entry();
          obj.display();
      }
  
  }
  
  class account {
      private String customer_name;
      private int acc_num;
      private double open_balance;
  
      public account() {
          customer_name="ADAM";
          acc_num=001;
          open_balance=100;
      }
  
      public void entry() {
          String customer_name=JOptionPane.showInputDialog(null, "Enter the customer name");
          String acc_num=JOptionPane.showInputDialog(null, "Enterthe account number");
          String open_balance=JOptionPane.showInputDialog(null, "Enter the balance");
  
          int acc_num1=Integer.parseInt(acc_num);
          double open_balance1=Double.parseDouble(open_balance);
      }
  
      public void display() {
          JOptionPane.showMessageDialog(null,customer_name);
      }
  
      public String getCustomer_name() {
          return customer_name;
      }
  }
  </code></pre>