Here you can find the source of clamp(int n, int min, int max)
public static int clamp(int n, int min, int max)
//package com.java2s; //License from project: LGPL public class Main { public static int clamp(int n, int min, int max) { if (n > max) return max; if (n < min) return min; return n; }/*ww w . jav a2s . com*/ }