Here you can find the source of clamp(int x, int a, int b)
public static int clamp(int x, int a, int b)
//package com.java2s; public class Main { public static int clamp(int x, int a, int b) { return (x < a) ? a : (x > b) ? b : x; }/*from w ww . ja v a2 s.c o m*/ }