static int clamp(int i,int min,int max){
  return Math.max(min,Math.min(i,max));
}

static int clamp ( int i , int min , int max ) { return Math . max ( min , Math . min ( i , max ) ) ; }
keeps i within min and max . min is of higher priority if min is larger than max .
