How to construct an Apache Commons Lang Rangelt;Integergt; object?(如何构建 Apache Commons Lang Rangelt;Integergt;目的?)
问题描述
如何创建 Apache Commons Lang 3.1 Range 对象?
JavaDocs 说:
<块引用>从最小值到最大值的不可变对象范围."
<块引用>
"这些对象要么是 Comparable 的实现,要么你需要提供一个 Comparator."
但是当我尝试时:
范围<整数>range = new Range<整数>(100, 200);我在我的 IDE 中收到一个错误,指出所需的参数是整数、整数、比较器.
尽管 Integer 实现了 Comparable 接口,因此我不需要额外的比较器.
谁能给我一个如何构造上述 Range 对象的例子?
Range 的构造函数似乎是私有的,因此静态方法可能是构造对象的首选方式.
例如,您可以使用静态方法 between 来构造 Range:
Range.between(100, 200);不过还有其他的静态方法,就看你需要什么了.
How can I create a Apache Commons Lang 3.1 Range<Inreger> object?
The JavaDocs say:
"An immutable range of objects from a minimum to maximum point inclusive."
"The objects need to either be implementations of Comparable or you need to supply a Comparator."
But when I try:
Range<Integer> range = new Range<Integer>(100, 200);
I get an error in my IDE that says required arguments are Integer, Integer, comparator.
Even though Integer implements the Comparable interface and thus I shouldn't need a extra comparator.
Can someone give me an example of how to construct the above described Range<Integer> object?
The constructor of Range appears to be private so a static method may be the preferred way of constructing the object.
For example, it looks like you could use the static method between to construct a Range:
Range.between(100, 200);
However there are other static methods, it just depends what you need.
这篇关于如何构建 Apache Commons Lang Range<Integer>目的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何构建 Apache Commons Lang Range<Integer>目的?
基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 使用堆栈算法进行括号/括号匹配 2022-01-01
