title: Java Error: Bad Operand Type for binary operator <
body: <pre><code>public class MaxMinArray&lt;T&gt;{
  
    private T getMin(T[] arr){
  
      T min = arr[0];
      for (int i = 0; i&lt;arr.length; i++){
        min = (arr[i] &lt; min) ? arr[i] : min;
      }
      return min;
    }
  
   public static void main(String[] args) {
  
    MaxMinArray&lt;Integer&gt; m = new MaxMinArray&lt;Integer&gt;();
    Integer[] arr = {1,2,3,4,5};
    System.out.println(m.getMin(arr));
  
    }
  
  }
  </code></pre>
  
  <p>I am getting the following error. I dont understand why can I not use &lt;, if T is a type variable and not an object ? </p>
  
  <pre><code>  error: bad operand types for binary operator '&lt;'
        if (arr[i] &lt; min){
                   ^
    first type:  T
    second type: T
    where T is a type-variable:
      T extends Object declared in class MaxMinArray
  </code></pre>
  
  <p>Also, since I am using T for generics, is it a good idea to define my array as Integer and not int. If not, how should I define an array of integers? </p>
  
  <p>Thank you! </p>