title: Comparing an array to two static values
body: <p>So I am just doing something simple. I made a simple Java program where you enter your guess for what the roll will be which is stored in an array and then compared to two  numbers generated randomly. So my question is how would I do  the comparison of the array against the two number without referencing  the exact index (i.e. not array[0]=number[1])? I am doing this mostly to figure out how array work. Also why is the else erroring?</p>
  
  <pre><code>public static void main (String [] args){
  
      java.util.Scanner input = new java.util.Scanner(System.in);
      int [] guess= new int [2];
      System.out.print("Enter " + guess.length + " values: ");
      for (int i=0; i&lt;guess.length;i++)
          guess[i] = input.nextInt();
  
      method(guess);
  
  
  
  }
  
  public static String method(int [] that){
      int number1 = (int)(Math.random() * 6);
      int number2 = (int)(Math.random() * 6);  
      for (int i =0;i&lt;that.length;i++){
          if(that[i]==number1 and that[i]+1==number2)
          {
              return "You got it";
          }
          else
          { 
              return "try again";
          }//end else
      } //end for
  }//end method
  </code></pre>