Java Integer Clamp clamp(int value, int min, int max)

Here you can find the source of clamp(int value, int min, int max)

Description

Ensures that a values does not leave a range.

License

Open Source License

Parameter

Parameter Description
value a parameter
min a parameter
max a parameter

Return

clamped value

Declaration

public static int clamp(int value, int min, int max) 

Method Source Code

//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);
    }
}

Related

  1. clamp(int val, int min, int max)
  2. clamp(int value, final int minimum, final int maximum)
  3. clamp(int value, int a, int b)
  4. clamp(int value, int low, int high)
  5. clamp(int value, int low, int high)
  6. clamp(int value, int min, int max)
  7. clamp(int value, int min, int max)
  8. clamp(int value, int min, int max)
  9. clamp(int value, int min, int max)