title: Calling a method from a different class to another class & method
body: <p>I have two classes, one called Driver and another called BankAccount. In Driver there is a method called Driver, and in BankAccount a method called Deposit. I'm getting an error that says, "non-static method Deposit() cannot be referenced from a static context" when I try to call BankAccount.Deposit from my Driver method.</p>
  
  <p>Any advice on what I should do to these lines of code to make it run.</p>
  
  <pre><code> import javax.swing.JOptionPane;
  public class Driver
  {
      int choice;
      String number;
      //public Driver()
      public Driver()
      {
           String number = JOptionPane.showInputDialog("1. Deposit 2. Withdraw 3. Balance 4. Change name 5. Exit");
           int choice = Integer.parseInt(number);
           do
           {
           if( choice == 1)
           {
               BankAccount.Deposit() = new Deposit();
               Driver.Driver = new Driver();
              }else if(choice == 2)
            {
                BankAccount.Withdrawl = new Withdrawl();
                Driver.Driver = new Driver();
              }else if(choice == 3)
              {
                 BankAccount.getBalance = new getBalance();
                 JOptionPane.showDialog(balance);
                 Driver.Driver = new Driver();
              }else if(choice == 4)
              {
                  name = JOptionPane.showInputDialog(" Please enter a name");
                  Driver.Driver = new Driver();
              }else if(choice ==5)
              {
                  JOptionPane.showDialog("Goodbye" + name);
              }
          }while( choice &gt;= 1 &amp;&amp; choice &lt;= 5);
  }
  }
  </code></pre>
  
  <p>here is the BankAccount Method</p>
  
  <pre><code> import javax.swing.JOptionPane;
  public class BankAccount
  {
  double balance = 400;
  double deposit;
  double withdraw;
  double Interest = 1.05;
  String name;
  String accountNumber;
  
  public BankAccount()
  {
  name = null;
  accountNumber = null;
  balance = 0;
  }
  
  public double Deposit()
  {
      String input = JOptionPane.showInputDialog("How much would you like to deposit?");
      deposit = Integer.parseInt(input);
      if (deposit &lt; 10000)
      {
          balance = (deposit + balance);
  
      }
      return balance;
  }
  
  }
  </code></pre>