Java 实例 - 查找 List 中的最大最小值

Java 教程 · 2019-02-11 18:29:20

以下实例演示了如何使用 Collections 类的 max() 和 min() 方法来获取List中最大最小值:

Main.java 文件

import java.util.*; public class Main { public static void main(String[] args) { List list = Arrays.asList("one Two three Four five six one three Four".split(" ")); System.out.println(list); System.out.println("最大值: " + Collections.max(list)); System.out.println("最小值: " + Collections.min(list)); } }

以上代码运行输出结果为:

[one, Two, three, Four, five, six, one, three, Four]
最大值: three
最小值: Four

点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html

查看所有标签

Convergence Culture

Convergence Culture

Henry Jenkins / NYU Press / 2006-08-01 / USD 30.00

"Convergence Culture" maps a new territory: where old and new media intersect, where grassroots and corporate media collide, where the power of the media producer, and the power of the consumer intera......一起来看看 《Convergence Culture》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具