Question: ```
int array[] = new int[]{10, 11, 88, 2, 12, 9};

public static int getMax(int[] inputArray){ 
  int maxValue = inputArray[0];

  for(int i=1;i < inputArray.length;i++){ 
     if(inputArray[i] > maxValue){ 
        maxValue = inputArray[i]; 
     } 
  } 
  return maxValue; 
}

```

Is there any way to find the maximum value but lower than 88 in the array?

Answer: 
If you use `Integer`s you can do it using a `TreeSet`

```
Integer[] values = new Integer[]{10, 11, 88, 2, 12, 9};
NavigableSet<Integer> integers = new TreeSet<>(Arrays.asList(values));

System.out.println(integers.lower(88));
System.out.println(integers.lower(2));
System.out.println(integers.lower(100));

```

prints out

```
12
null
88

```

The javadoc of [`NavigableSet.lower(E e)`](https://docs.oracle.com/javase/7/docs/api/java/util/NavigableSet.html#lower(E)) says:

> 
> Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
> 
> 
>
You're probably looking for something like this: 

```
public static int getMax(final int[] inputArray) {

    final int L = 88;

    int maxValue = inputArray[0];

    for (int i = 1; i < inputArray.length; i++) {
        if (maxValue < L)
            break;
        maxValue = inputArray[i];
    }

    for (final int element : inputArray) {
        if (element >= L)
            continue;
        if (element > maxValue)
            maxValue = element;
    }
    return maxValue;
}

```

Please be aware that the (some of the) other answers fail if `inputArray[0] >= 88`.