Java tutorial
//package com.java2s; public class Main { public static int adjust(final int value, final int min, final int max) { return Math.min(Math.max(min, value), max); } }