Java Number Range Check inRange(E element, E min, E max)

Here you can find the source of inRange(E element, E min, E max)

Description

in Range

License

LGPL

Declaration

public static <E extends Comparable<E>> boolean inRange(E element, E min, E max) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static <E extends Comparable<E>> boolean inRange(E element, E min, E max) {
        int toMin = element.compareTo(min);
        int toMax = element.compareTo(max);
        return toMin == 0 ? true : toMin < 0 ? false : toMax == 0 ? true : toMax > 0 ? false : true;
    }/*  ww  w.j a v  a2 s  .  c  o m*/
}

Related

  1. inRange(double value, double lower, double upper)
  2. inRange(double value, double min, double max)
  3. inRange(double value, double min, double max)
  4. inRange(double value, double target, double range)
  5. inRange(double x, double y, double z, double sx, double sy, double sz, double r)
  6. inRange(final float testNum, final float min, final float max)
  7. inRange(final int id, final int min, final int max)
  8. inRange(final int value, final int min, final int max)
  9. inRange(final int value, final int min, final int max, final String fieldName)