Getting partition boundaries in sorted integer array using only equalTo operator
In general single letter variables are okay, but here short names like first and last would be more readable.

Also java has a very strong convention of always using braces {}, and an indentation of 4 spaces. (Historically C/C++ had normally 3, and one whished less nesting of code due to the "superior" quality of the new language.)

List as interface is more generic than ArrayList, so do not overspecify, be too restrictive.

Using an exclusive upperbound is often done in computer science, and indeed in the java APIs themselve. Here it would mean having partions [f, l&gt; like [a, b&gt;, [b, c&gt;, [c, d&gt;, [d, e&gt;. So at the end of the range searching loop f = l;.

   public void printPartitionBoundaries(List&lt;Integer&gt; array)
   {
      int f = 0;
      int l = array.size(); // Upperbound exclusive
      while (f &lt; l) {
         int cp = array.get(f);


of (old first) is a leftover.

The loop with done: done could be removed, a while (true) would
work as well. Hence use the first if-condition as while-condition.

Also m was calculated too early.

Also == false and == true should really not be seen.

The nested ifs can be simplified.

Mind that the condition treats two cases of 1 element and 0 elements. Simpler would be while (f &lt; l).

         while ((l-f) &gt; 1)
         {
            int m = (f + l)/2;
            if (!array.get(f).equals(array.get(l))
                   &amp;&amp; !array.get(f).equals(array.get(m))) {
               l = m;
            } else {
               f = m;
            }
         }


I wonder about the correctness; somehow one expects f = m + 1; to have a loop variant (l-f) diminishing every step.

The following if-statement on l == array.size() should become:

         System.out.println("Value " + cp + " is till " + (l-1) + " index");


Check, maybe the while-condition should become &gt; 0, and extra step more.

         f = l;
         l =  array.size();
      }
   }


To verify the correctness I leave up to you yourself.



Resulting code:

   public void printPartitionBoundaries(List&lt;Integer&gt; array)
   {
      int f = 0;
      int l = array.size(); // Upperbound exclusive
      while (f &lt; l) { // f != l
         int cp = array.get(f);
         while ((l-f) &gt; 1) // maybe better f != l too
         {
            int m = (f + l)/2;
            if (!array.get(f).equals(array.get(l))
                   &amp;&amp; !array.get(f).equals(array.get(m))) {
               l = m;
            } else {
               f = m;
            }
         }
         System.out.println("Value " + cp + " is till " + (l-1) + " index");
         f = l;
         l =  array.size();
      }
   }