title: How to correctly implement assignment mutator methods ( += , /= , etc ) for class member variables , in Java
body: <p>Java doesn't support operator overloading , so when I want to plus_equals [ += ]  two objects like this :</p>
  
  <pre><code>    // pseudo : a += b ; 
  </code></pre>
  
  <p>In Java I have to write : </p>
  
  <pre><code>    a . set ( a . add ( b ) ) ; 
  </code></pre>
  
  <p>Which can be wrapped in a method to more closely mimic the syntax of the "+=" operator to get :</p>
  
  <pre><code>    a . add_equals ( b ) ; 
  </code></pre>
  
  <p>When I try to do the same for class member variables like this :</p>
  
  <pre><code>    // pseudo : a.x += a.x ; 
      a . setX ( add ( a.getX() , b.getX() ) ) ; 
  </code></pre>
  
  <p>I encounter a problem - the getters and setters get in the way . 
  I either have to directly access the augend ( a.x ) of the addition which means I have to make it public ... </p>
  
  <pre><code>    a . getX ( ) . add_equals ( b . getX() ) ; 
  </code></pre>
  
  <p>or I have to make a kinda confusing looking mutator method </p>
  
  <pre><code>    a . setX_add_equals ( b.getX() ) ; 
  </code></pre>
  
  <p>Is there an elegant solution to this problem that both :</p>
  
  <p>( 1 ) - Doesn't interfere with the access modifiers of the member variables .</p>
  
  <p>( 2 ) - Is intuitive in terms of readability . </p>
  
  <p>In advance , thanks for your time . </p>