title: How do I make a comparison between the objects in a vector and an int? : Java
body: <p>I am trying to use an if condition to compare the objects in a vector, which represent integers, with values of type int, so that I can increment those which appear in the vector according to how many times they appear in the vector. I can't for the life of me get it to compile. Here is the code.</p>
  
  <pre><code>package countjava;
  import java.util.*;
  
  public class Count {
  
      public static void main(String[] args) {
  
          Vector vect = new Vector();
          int[] amounts = new int[100];
  
          for (int i = 0; i &lt;= 9999; i++) {
              VectorIntObject intObject = 
                      new VectorIntObject((int)Math.random() * 100);
              vect.add(intObject);
          }
  
          Collections.sort(vect);
          for (int i =0; 1 &lt; 40; i++) {
              System.out.println(vect.get(i));
          }
  
          for (int i = 0; i &lt; 10; i++) {
              for (int j = 0; j &lt;= 99; j++) {
                  Object ourObject = vect.get(i);
                  if (ourObject.getVectorIntValue() == j) {
                      amounts[j]++;
                  }
              }
          }
  
          for (int j = 0; j &lt;= 99; j++) {
                  System.out.println(amounts[j]);
          }
      }
  }
  
  class VectorIntObject {
      int value;
      public VectorIntObject(int value) {
          this.value = value;
      }
  
      public int getVectorIntValue() {
          return this.value;
      }
  }
  </code></pre>
  
  <p>The comparison should happen in the nested for loops about half way down. Any help would be much appreciated. Thanks.</p>