Here you can find the source of clamp(int value, int min, int max)
Parameter | Description |
---|---|
value | a parameter |
min | a parameter |
max | a parameter |
public static int clamp(int value, int min, int max)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww. j a v a 2s . com*/ * Ensures that a values does not leave a range. * * @param value * @param min * @param max * @return clamped value */ public static int clamp(int value, int min, int max) { return Math.min(Math.max(value, min), max); } }