Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * If value >= max returns max. If value <= min returns min. Otherwise returns value.
     */
    public static int clamp(int value, int min, int max) {
        return Math.max(Math.min(value, max), min);
    }

    /**
     * If value >= max returns max. If value <= min returns min. Otherwise returns value.
     */
    public static float clamp(float value, float min, float max) {
        return Math.max(Math.min(value, max), min);
    }
}