getMinimum()
is an instance method of the Range
class that is used to get the minimum value in the range.
Range
We can find the definition of Range
in the Apache Commons Lang
package, which we can add to the Maven project by adding the following dependency to the pom.xml
file:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
For other versions of the
commons-lang
package, refer to the Maven Repository.
We can import the Range
class as follows:
import org.apache.commons.lang3.Range;
public T getMinimum()
This method has no parameters.
The getMinimum()
method returns the minimum value in the range.
import org.apache.commons.lang3.Range;public class Main{public static void main(String[] args) {int fromValue = 100;int toValue = 200;Range<Integer> range = Range.between(fromValue, toValue);System.out.printf("Range object - %s\n", range);System.out.println("Minimum value - " + range.getMinimum());}}
3
, we define the Main class.5
, we define the main method.6
, we define the minimum/fromValue
of the range.7
, we define the maximum/toValue of the range.8
, we use the between
method to get the Range
object.9
, we print the Range
object.10
, we use the getMinimum()
method to get the minimum value of the range.The output of the code will be as follows:
Range object - [100..200]
Minimum value - 100