Here you can find the source of clamp(int min, int value, int max)
public static int clamp(int min, int value, int max)
//package com.java2s; //License from project: Open Source License public class Main { public static int clamp(int min, int value, int max) { return Math.min(max, Math.max(min, value)); }//from w ww . j a v a2 s . c om public static long clamp(long min, long value, long max) { return Math.min(max, Math.max(min, value)); } public static float clamp(float min, float value, float max) { return Math.min(max, Math.max(min, value)); } public static double clamp(double min, double value, double max) { return Math.min(max, Math.max(min, value)); } }