title: Calling an external class object from function on main class
body: <p>I am writing a program that keeps track of different transactions
  done over time. I have a main class, and also another class named 
  <code>CheckingAccount.java</code>.</p>
  
  <p>I have a main class formatted this way.</p>
  
  <pre><code>public class Main
  {
     public static void main (String[] args)
     { 
           CheckingAccount c = new CheckingAccount(bal);
           --line of code---
           --line of code---
           --line of code---          
     }
  
     public static int getTransCode()
     {
           --line of code---
     }
     public static double getTransAmt()
     {
           --line of code---
     }
     public static void processCheck(double trAm, int tCode, boolean monthCh)
     {
          double curCharge=0.15;
  
          CheckingAccount.setBalance(trAm,tCode,curCharge,monthCh);
          CheckingAccount.setServiceCharge(curCharge);
     }
     public static void processDeposit(double trAm, int tCode, boolean monthCh)
     {
          double curCharge=0.10;
  
          CheckingAccount.setBalance(trAm,tCode,curCharge,monthCh);
          CheckingAccount.setServiceCharge(curCharge);
     } 
  }
  </code></pre>
  
  <hr>
  
  <p>This is my CheckingAccount.java</p>
  
  <pre><code>public class CheckingAccount
  {
     private double balance;
     private double totalServiceCharge;
  
     public CheckingAccount(double initialBalance)
     {
          balance = initialBalance;
          totalServiceCharge = totalServiceCharge;
     }
  
     public double getBalance()
     {
          return balance;
     }
  
     public void setBalance(double tAm, int Code, double charge, boolean mChrg)
     {
          if(tCode == 1)
          balance = (balance - tAm) - charge;
          else //if(tCode == 2)
              balance = (balance + tAm) - charge;
     }
  
     public double getServiceCharge()
     {
          return totalServiceCharge;
     }
  
     public void setServiceCharge(double currentServiceCharge)
     {
          totalServiceCharge = totalServiceCharge+currentServiceCharge;
     }
  }
  </code></pre>
  
  <p>So the lines I can't get to work are <code>CheckingAccount.setBalance()</code> and <code>CheckingAccount.setServiceCharge()</code> inside the functions on my main class. What I'm trying to do is to call the the methods I created (<code>setBalance</code>, and <code>setServiceCharge</code>) in my class, from functions that I created on my main class (<code>processCheck</code>, and <code>processDeposit</code>).</p>
  
  <p>But I cannot get it to run, I keep running with these error messages.</p>
  
  <blockquote>
    <p><strong>non-static method setBalance(double,int,double,boolean) cannot be referenced from a static context
            CheckingAccount.setBalance(trAm,tCode,curCharge,monthCh);</strong></p>
  </blockquote>