您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 楚雄分类信息网,免费分类信息发布

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

2024/4/10 22:43:18发布14次查看
以下实例演示了如何使用 collections 类的 max() 和 min() 方法来获取list中最大最小值:
/* author by w3cschool.cc 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 实例 - 查找 list 中的最大最小值的内容。
楚雄分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录