title: How can I do binary search in java ArrayList<Long>?
body: <p>I am trying to make binary search in ArrayList, but the binarySearch method does not work for Long, as well as Double and Float. My code is</p>
  
  <pre><code>import java.util.*;
  
   public class BinarySearchInArrayList
   {
       public static void main(String[]args)
       {
           ArrayList&lt;Long&gt; ar = new ArrayList();
  
           for(long l = 1;l&lt;100000;l++)
           {
               ar.add(l);
           }
  
           System.out.println("arraylist: "+ar); 
           System.out.println("Which number's index do you want to know? ");
           Scanner scan = new Scanner(System.in);
           int p = scan.nextInt();
           int index = Collections.binarySearch(ar,p);
           System.out.println("number "+p+" has index "+index);
       }
  </code></pre>
  
  <p>When I use Integer instead of <code>Long</code>, it works fine, but I want to make it with <code>Long</code>. Can you help me, please?</p>