title: The type of the expression must be an array type but it resolved to int - same syntax as an array that works?
body: <p>I have two arrays, both as <code>int</code> types. The <code>costs[]</code> array works perfectly, without errors or bugs, but the <code>stands</code> array, which is coded exactly the same, gives the error "The type of the expression must be an array type but it resolved to int" in a method I define near the bottom of the program called <code>buttonFunc</code>. In the <code>init()</code> method, I call <code>stands[1] = 0</code> and that works fine, but when I do nearly the same thing (replacing the 1 with an integer defined when you call the method), it gives me the error. Why is it that two arrays, exactly the same in syntax and usage, can do this?</p>
  
  <pre><code>`import java.applet.Applet;
  import java.awt.BorderLayout;
  import java.awt.Button;
  import java.awt.Canvas;
  import java.awt.FlowLayout;
  import java.awt.Graphics;
  import java.awt.Image;
  import java.awt.Rectangle;
  import java.awt.Toolkit;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.image.BufferStrategy;
  import java.text.DecimalFormat;
  
  import javax.swing.Timer;
  
  
  public class Main extends Applet implements Runnable, ActionListener {
      private static final long serialVersionUID = 1L;
  
      double money = 0;
      double income = 2; //Actual income is this * 0.4
      //int lemonadeStands = 0;
      int cookieStands = 0;
      int cupcakeStands = 0;
      int cookieCost = 25;
      int cupcakeCost = 75;
      int modifier = 1;
  
      int[] costs = new int[3];
      int[] stands = new int[3];              //Declaring the array - same as the costs[] array, but it doesn't work?
  
      Button buyLemonade;
      Button buyCookie;
      Button buyCupcake;
  
      int time = 0;
      int timeComparison = (int) (Math.random()*50 + 120);
  
      private Graphics dBufferedGraphic = null;
      private Image dbufferedImage = null;
  
      public void init() {
          costs[1] = 10;
          stands[1] = 0;                  //No error here?
  
          setLayout(new FlowLayout());
          buyLemonade = new Button("Buy a Lemonade Stand");
          buyCookie = new Button("Buy a Cookie Stand");
          buyCupcake = new Button("Buy a Cupcake Stand");
  
          add(buyLemonade);
          add(buyCookie);
          add(buyCupcake);
  
          buyLemonade.addActionListener(this);
          buyCookie.addActionListener(this);
          buyCupcake.addActionListener(this);
  
          t.start();
      }
  
      public void paint(Graphics g) {
          DecimalFormat df = new DecimalFormat("#.##");
          g.drawString("Money: $" + df.format(money), 10, 10);
          g.drawString("Income: $" + income / 2.5 + " per second", 10, 24);
          g.drawString("Lemonade Stands: " + stands[1], 10, 52);
          g.drawString("Cookie Stands: " + cookieStands, 10, 66);
          g.drawString("Cupcake Stands: " + cupcakeStands, 10, 80);
          g.drawString("Cost: " + costs[1], 355, 40);
          g.drawString("Cost: " + cookieCost, 495, 40);
          g.drawString("Cost: " + cupcakeCost, 620, 40);
      }
  
      public void run() {}
      public void start() {}
      public void stop() {}
      public void destroy() {}
  
      Timer t = new Timer(50, new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              money += income / 50; //0.8 per second
              repaint();
          }
       });
  
      public void actionPerformed(ActionEvent e) {
          /*if(e.getSource() == buyLemonade) {
              if (money &gt;= lemonadeCost) {
              System.out.println("Lemonade stand bought. ");
              income += 1; //0.4 actual
              lemonadeStands++;
              money -= lemonadeCost;                      Replacing with method.
              lemonadeCost += 4 * modifier; 
              modifier++;
              }else System.out.println("Not enough money! ");
          }*/
          buttonFunc(costs[1], 1, stands[1], 1, "Lemonade stand", 1);
          if(e.getSource() == buyCookie) {
              if (money &gt;= cookieCost) {
              System.out.println("Cookie stand bought. ");
              income += 3;
              cookieStands++;
              money -= cookieCost;
              cookieCost += 8 * modifier;
              modifier += 2;
              }else System.out.println("Not enough money! ");
          }
          if(e.getSource() == buyCupcake) {
              if (money &gt;= cupcakeCost) {
              System.out.println("Cupcake stand bought. ");
              income += 6;
              cupcakeStands++;
              money -= cupcakeCost;
              cupcakeCost += 18 * modifier;
              modifier += 3;
              }else System.out.println("Not enough money! ");
          }
      }
  
      public void buttonFunc(int cost, int incomeProduced, int stands, int modifierAmount, String name, int arrayLocation) {
          if (money &gt;= cost) {
              System.out.println(name + " bought. ");
              income += incomeProduced;
              stands[arrayLocation] += 1;                 //Where I get the error
              money -= cost;
              costs[arrayLocation] = (int) (costs[arrayLocation]  + costs[arrayLocation] * 0.4);
              modifier += modifierAmount;
          }else System.out.println("Not enough money! ");
      }
  
      public void update (Graphics g) {
          if (dbufferedImage == null) {
                  dbufferedImage = createImage(this.getSize().width, this.getSize().height);
                  dBufferedGraphic = dbufferedImage.getGraphics ();
              }
            dBufferedGraphic.setColor(getBackground ());
            dBufferedGraphic.fillRect(0, 0, this.getSize().width, this.getSize().height);
  
            dBufferedGraphic.setColor(getForeground());
            paint(dBufferedGraphic);
  
            g.drawImage(dbufferedImage, 0, 0, this);
      }
  
  }
  </code></pre>