title: When to use "this" in Java
body: <p>I apologize for my trivial and probably silly question, but I am a bit confused as to when to use the "this" prefix when using a method or accessing something.</p>
  
  <p>For example, if we look at #4 
  here:
  <a href="http://apcentral.collegeboard.com/apc/public/repository/ap_frq_computerscience_12.pdf">http://apcentral.collegeboard.com/apc/public/repository/ap_frq_computerscience_12.pdf</a></p>
  
  <p>And we look at the solutions here:
  <a href="http://apcentral.collegeboard.com/apc/public/repository/ap12_computer_science_a_q4.pdf">http://apcentral.collegeboard.com/apc/public/repository/ap12_computer_science_a_q4.pdf</a></p>
  
  <p>We see that one solution to part a) is </p>
  
  <pre><code>public int countWhitePixels() { 
  int whitePixelCount = 0; 
      for (int[] row : this.pixelValues) { 
        for (int pv : row) { 
        if (pv == this.WHITE) { 
        whitePixelCount++; 
        }
       } 
     } 
  return whitePixelCount; 
  } 
  </code></pre>
  
  <p>while another solution is </p>
  
  <pre><code> public int countWhitePixels() { 
   int whitePixelCount = 0; 
       for (int row = 0; row &lt; pixelValues.length; row++) { 
        for (int col = 0; col &lt; pixelValues[0].length; col++) { 
        if (pixelValues[row][col] == WHITE) { 
        whitePixelCount++; 
       } 
     } 
   } 
   return whitePixelCount; 
  } 
  </code></pre>
  
  <p>Here is my question. Why is it that they use the "this." prefix when accessing pixelValues and even WHITE in the first solution, but not in the second? I thought "this" was implicit, so am I correct in saying "this." is NOT necessary at all for the first solution?</p>
  
  <p>Thank you SO much for your help :)</p>