public static int between(int val,int min,int max){
  return Math.max(Math.min(val,max),min);
}

public static int between ( int val , int min , int max ) { return Math . max ( Math . min ( val , max ) , min ) ; }
check if value within allowed range .
