Thanks for your ideas @fishercoder. I tried for a clean version

class Solution {
public int numSubarrayProductLessThanK(int[] nums, int k) {
int count = 0, left = 0, right = 0, prod = 1;
while(right < nums.length){
prod *= nums[right++];
while(prod >= k && left < right)
prod /= nums[left++];
count += right - left;
}
return count;
}
}