admin 管理员组文章数量: 888136
2024年1月11日发(作者:清华python)
return object; } object = (obj); return object; }}
package PjectUtils;import DateFormat;import ;/** *
* @author yinaibang * */public class UserInfo implements izable { private static final long serialVersionUID = -3522732L; private Integer userId; private String username; private Date birthDate; private Integer age; private float fRate; private char ch; public Date getBirthDate() { return birthDate; } public String getBirthDatestr() { SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd"); return (getBirthDate()); } public UserInfo(Integer userId, String username, Date birthDate, Integer age, float fRate, char ch) { super(); = userId; me = username; ate = birthDate; = age; = fRate; = ch; } @Override public String toString() { return "UserInfo [userId=" + userId + ", tusername=" + username + ", tbirthDate=" + getBirthDatestr() + ", tage=" + age + ", fRate=" + fRate + ", ch=" + ch + "]"; }}package PjectUtils;import DateFormat;import ist;import ;/** *
* @author yinaibang * */public class ListUtilsTest { public static void main(String[] args) throws Exception { ListUtilsTest testObj = new ListUtilsTest(); List
(user6); (user7); (user8); n("n-------原来序列-------------------"); UserInfoList(list); // 按userId升序、username降序、birthDate升序排序 String [] sortNameArr = {"userId","username","birthDate"}; boolean [] isAscArr = {true,false,true}; (list,sortNameArr,isAscArr); n("n--------按按userId升序、username降序、birthDate升序排序(如果userId相同,则按照username降序,如果username相同,则按照birthDate升序)------------------"); UserInfoList(list);
// 按userId、username、birthDate都升序排序 (list, true, "userId", "username","birthDate"); n("n--------按userId、username、birthDate排序(如果userId相同,则按照username升序,如果username相同,则按照birthDate升序)------------------"); UserInfoList(list); // 按userId、username都倒序排序 (list, false, "userId", "username"); n("n--------按userId和username倒序(如果userId相同,则按照username倒序)------------------"); UserInfoList(list); // 按username、birthDate都升序排序 (list, true, "username", "birthDate"); n("n---------按username、birthDate升序(如果username相同,则按照birthDate升序)-----------------"); UserInfoList(list); // 按birthDate倒序排序 (list, false, "birthDate"); n("n---------按birthDate倒序-----------------"); UserInfoList(list); // 按fRate升序排序 (list, true, "fRate"); n("n---------按fRate升序-----------------"); UserInfoList(list); // 按ch倒序排序 (list, false, "ch"); n("n---------按ch倒序-----------------"); UserInfoList(list); } private void printfUserInfoList(List
版权声明:本文标题:javalist按照对象指定多个字段属性进行排序 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1704985482h468625.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论