title: accessing variables using loop counter in java, android
body: <p>how can I access declared variables using counter, in a loop, like this:</p>
  
  <p>declared variables:</p>
  
  <pre><code>Button square0, square1, square2, square3, square4, square5, square6,
          square7, square8, temp;
  </code></pre>
  
  <p>accessing them with a loop like this:</p>
  
  <pre><code>for (int i = 0; i &lt; 9; i++) {
      (Button) ("square"+i).setBackgroundResource();
  </code></pre>