如何构建apache commons 3.1 Range< Integer>目的 [英] how to construct a apache commons 3.1 Range<Integer> object

查看:143
本文介绍了如何构建apache commons 3.1 Range< Integer>目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建apache公共3.1范围对象?

How can I create a apache commons 3.1 Range object?

java docs 说:


从最小点到最大点的不可变对象范围。

对象需要或者是Comparable的实现,或者你需要提供Comparator。

但是当我尝试时:

Range<Integer> range = new Range<Integer>(100, 200);

我的IDE中出现错误,指出所需的参数是Integer,Integer,comparator。

I get an error in my IDE that says required arguments are Integer, Integer, comparator.

尽管Integer实现了Comparable接口,因此我不需要额外的比较器。

Even though Integer implements the Comparable interface and thus I shouldn't need a extra comparator.

有人能举例说明如何构建apache公共3.1范围对象吗?

Can someone give me an example of how to construct a apache commons 3.1 Range object?

推荐答案

Range的构造函数似乎是私有的,因此静态方法可能是构造对象的首选方法。

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 3.1 Range&lt; Integer&gt;目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆