本教程将介绍如何构建 Apache Commons Lang Range<Integer>目的?的处理方法,这篇教程是从别的地方看到的,然后加了一些国外程序员的疑问与解答,希望能对你有所帮助,好了,下面开始学习吧。
问题描述
怎么创建 Apache Commons Lang 3.1 Range
对象?
JavaDocs 说:
“
""
但是当我尝试时:
范围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:
""
""
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>目的?的教程就到这里就结束了,希望趣模板源码网找到的这篇技术文章能帮助到大家,更多技术教程可以在站内搜索。