如何在给定变量的Java中对列表进行排序

编程入门 行业动态 更新时间:2024-10-10 15:21:22
本文介绍了如何在给定变量的Java中对列表进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在Java中知道如何根据单个变量对列表对象进行排序. 例如: 假设我有

i want to know in java, how to sort the list object based on a single variable. ex: suppose i have

class student { string name; float avg; }

我创建一个列表并传递对象int列表,现在我想对avg进行详细排序.

and i create a list and pass the object int list , now I want to sort the details on avg.

推荐答案

请参阅此Java教程 [ ^ ]. <编辑>粘贴后应该检查链接.很遗憾,它缺少html中的"l". See this Java Tutorial[^]. <Edit> Should have checked the linked after pasting it. It was missing the ''l'' from html.

对不起,以上链接不再存在.认为Oracle已对其进行了更新: download.oracle/javase/tutorial/collections/algorithms/index.html 无论哪种方式,答案都位于Comparable或Comparator界面中. 干杯 sorry, the above link does not exist any more. Think Oracle have updated it : download.oracle/javase/tutorial/collections/algorithms/index.html Either way the answer lies in the Comparable or Comparator interface. Cheers

更多推荐

如何在给定变量的Java中对列表进行排序

本文发布于:2023-11-29 08:57:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645933.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中对   变量   如何在   列表   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!