title: How to display images using for loop in java
body: <p>someone please help. I am trying to display an image of a brick layer by layer but when i run my code it just displays one brick at the position where the loop ends. Thanks for helping me out.</p>
  
  <pre><code>public class Game extends JApplet{
  
     Image [][] bricks = new Image[3][15]; 
  
     public void init()
      {
          Image brick = getImage(getDocumentBase(),"brick.png");
  
          for(int i =0; i &lt; bricks.length; i++)
              for(int j = 0; j &lt; bricks[0].length; j++)
                      bricks[i][j] = brick;
  
  
      }
  
      public void paint (Graphics g)
      {
         for (int i = 0; i &lt; bricks.length; i++)
          for ( int j =0; j &lt; bricks[0].length; j++)
              g.drawImage(bricks[i][j],i+85,j+30, this);
  
      }
  }
  </code></pre>