public static int clamp(int value,int minValue,int maxValue){
  return Math.max(minValue,Math.min(value,maxValue));
}

public static int clamp ( int value , int minValue , int maxValue ) { return Math . max ( minValue , Math . min ( value , maxValue ) ) ; }
limit an integer value to a specific range .
