title: Java - when to use 'this' keyword
body: <p>What is the best practise for using the <code>this</code> keyword in Java? For example, I have the following class:</p>
  
  <pre><code>class Foo {
      Bar bar;
  
      public Foo(Bar bar) {
           this.bar = bar;
      }
  }
  </code></pre>
  
  <p>That's fine and all, but Java is clever enough to know what is happening if I change the statement in the constructor to</p>
  
  <pre><code> bar = bar;
  </code></pre>
  
  <p>So why use the <code>this</code> keyword? (I realise in some situations, it's totally necessary to use it, I'm just asking for situations like this). Actually, I tend to use the keyword purely for readability sake but what's the common practise? Using it all over the shop makes my code look a bit messy, for example</p>
  
  <pre><code>boolean baz;
  int someIndex = 5;
  this.baz = this.bar.getSomeNumber() == this.someBarArray[this.someIndex].getSomeNumber();
  </code></pre>
  
  <p>Obviously a poor bit of code but it illustrates my example. Is it just down to personal preference in these cases?</p>