I am trying to get all the values in an array that are below the BigDecimal value specified by the user. This is what I have so far:
class MyClass {
public static void mymethod(BigDecimal[] values, BigDecimal uservalues) {
for (int i = 0; i < values.length(); i++) {
System.out.prinln(String.valueof(list.get(i)));
}
}
}
I’m not understanding the logic of how to do this.
So lets say values has the following values:
24.50
23.58
24.68
21.68
2.05
48.36
USER INPUT: 23
2.05
21.68
Hopefully my question is clear. Could anyone provide any tips?
Use
NavigableSet.headSet🙂This is likely an easier solution than manually iterating and using
compareTo.