title: Accessing variables in different classes in Android
body: <p>So say a user enters a total in an EditText field in my Incomings class, I then want this to be passed to my Results class. How do I go about this in Android? I know the best way is to use Accessor methods.
  My Incomings class:</p>
  
  <pre><code>public void onClick(View v) {
  
  String userLoan = etLoan.getText().toString();
  String userGrant = etGrant.getText().toString();
  String userFirst = etFirst.getText().toString();
  
  float fUserLoan = Float.parseFloat(userLoan);
  float fUserGrant = Float.parseFloat(userGrant);
  float fUserFirst = Float.parseFloat(userFirst);
  
  float totalIncomings = fUserLoan + fUserGrant + fUserFirst;
  
  Intent intent = new Intent(v.getContext(), Outgoings.class);
  startActivity(intent);
  
  }
  });
  </code></pre>
  
  <p>My results class has a blank function and will calculate the totals
  I have tried using accessor methods in my MainAcivity class:</p>
  
  <pre><code>public float getTotalOutgoings() {
      return totalOutgoings;
  }
  
  public void setTotalOutgoings(float totalOutgoings) {
      this.totalOutgoings = totalOutgoings;
  }
  
  public float getTotalIncomings() {
      return totalIncomings;
  }
  
  public void setTotalIncomings(float totalIncomings) {
      this.totalIncomings = totalIncomings;
  }
  
  public float getTotalResult() {
      return totalResult;
  }
  
  public void setTotalResult(float totalResult) {
      this.totalResult = totalResult;
  } 
  </code></pre>
  
  <p>Any suggestions?</p>