Finding the count of all repeats in an array of integers
Your code has a for-loop with a nested while-loop. Typically this would indicate an \$O(n^2)\$ time complexity for your solution.... but, your code is only actually \$O(n)\$... how does that happen?

Because you do for-loop control variable manipulation outside the for-loop control block. This is a bad practice. A for loop has three control statements: for (initializer, terminator, stepper). A for loop is designed to have those three mechanisms in one place. In your code, you have split the logic of the stepper in to two places, which makes the for-loop hard to read, and unconventional. Your i variable is stepped, and also you have i=j-1; later in your loop.

If you cannot implement a clean for-loop structure because your code demands some other mechanism, then you should instead use a while-loop, or find a different way to express your step-process.

Bhushan has provided an answer which solves the problem, but does not implement a clean break-processing loop. His code implements the logic check when leaving a clump, rather than when entering the clump. If you do the check when the clump starts, the logic becomes much simpler:

public int countClumps(int[] nums) {
  boolean inclump = false;
  int clumpcnt = 0;
  // note the start-from-1 loop
  for (int i = 1; i &lt; nums.length; i++) {
      if (nums[i] == nums[i - 1]) {
          // we are in a clump
          if (!inclump) {
              // this is the first time for this clump.
              inclump = true;
              clumpcnt++;
          }
      } else {
          inclump = false;
      }
  }
  return clumpcnt;
}