title: Unresolved compilation, “XX” cannot be resolved to a variable
body: <p>I am trying to find a mode of an array of <code>ints</code> in Java. </p>
  
  <p>I am getting the exception: </p>
  
  <p>"Exception in thread "main" java.lang.Error: Unresolved compilation problem: maxValue cannot be resolved to a variable at tez3.main(tez3.java:34)" error.</p>
  
  <p>My code is below. What is the problem?</p>
  
  <p>Update: Solved, i am adding the code below. Thanks to Elliott Frisch</p>
  
  <pre><code>import java.util.Scanner;
  import java.io.*;
  import java.util.ArrayList;
  
  public class tez3
  {
  public static void main (String args[]) throws java.io.IOException
  {
  Scanner s = new Scanner(new File("C:\\tny\\Deneme1.txt"));
  int [] numberList = new int [10];
  int i = 0;
  int count = 0;
  int result = 0;
  while(s.hasNextInt()){
      numberList[i++] = s.nextInt();
  }
  for (i=0; i&lt;numberList.length;i++)
  {
      System.out.println(+(i+1) +".Value: " +numberList[i]);
  }
  for (i=0; i&lt;numberList.length;i++)
  {
      count++;
  }
  
  for (i=0; i&lt;numberList.length;i++)
  {
          result += numberList[i];
  }
  
  System.out.println("Average of the Values is: " +result/count);
  System.out.println("Mode of the Values is: " +mode(numberList));   
  }
  
  public static int mode(int numberList[])
  {
  int maxValue=0, maxCount=0;
  
  for (int i = 0; i &lt; numberList.length; ++i) {
      int count = 0;
      for (int j = 0; j &lt; numberList.length; ++j) {
          if (numberList[j] == numberList[i]) ++count;
      }
      if (count &gt; maxCount) {
          maxCount = count;
          maxValue = numberList[i];
      }
  }
  
  return maxValue;
  }
  
  }
  </code></pre>