Here you can find the source of clamp(int value, int low, int high)
public static int clamp(int value, int low, int high)
//package com.java2s; //License from project: Apache License public class Main { /**// w w w . j a v a 2 s . c om * Clamps the supplied {@code value} to between {@code low} and {@code high} (both inclusive). */ public static int clamp(int value, int low, int high) { if (value < low) return low; if (value > high) return high; return value; } }