Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static int adjust(final int value, final int min, final int max) { return Math.min(Math.max(min, value), max); } public static float adjust(final float value, final float min, final float max) { return Math.min(Math.max(min, value), max); } public static int min(final int... values) { int min = Integer.MAX_VALUE; for (final int v : values) { min = Math.min(v, min); } return min; } public static int max(final int... values) { int max = Integer.MIN_VALUE; for (final int v : values) { max = Math.max(v, max); } return max; } }