下面列出了org.apache.commons.lang3.math.NumberUtils#max ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void lang() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
String[] strs = new String[]{"1", "4", "2"};
ArrayUtils.addAll(strs, "3");
RandomUtils.nextInt(0, 10);
RandomStringUtils.random(3);
StopWatch stopWatch = new StopWatch();
stopWatch.start();
stopWatch.split();
stopWatch.getSplitTime();
stopWatch.suspend();
stopWatch.resume();
stopWatch.stop();
stopWatch.getTime();
long max = NumberUtils.max(new long[]{1, 5, 10}); //计算数组最大值
MethodUtils.invokeStaticMethod(StringUtils.class, "isNotBlank", "test"); //调用静态方法
MethodUtils.invokeMethod(StringUtils.class, "isNotBlank", "test"); //调用静态方法
DateUtils.truncate(new Date(), Calendar.HOUR);
DateFormatUtils.format(new Date(), "yyyyMMdd");
}
@Nullable
public Double max() {
if (items.isEmpty()) {
return null;
}
return NumberUtils.max(ArrayUtils.toPrimitive(items.toArray(new Double[items.size()])));
}
@Test
public void find_max_value_in_array_with_apache_commons () {
int highest = NumberUtils.max(numbers);
assertEquals(91, highest);
}
/**
* 取一个长度单位的起始index
*
* @param content 待处理文本
* @return 返回文本中包含的一个长度单位的起始index
*/
private int getNearCode(String content) {
return NumberUtils.max(StringUtils.lastIndexOf(content, COLON_STRING), StringUtils.lastIndexOf(content, BLANK_STRING));
}