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 list = new ArrayList(); // public UserInfo(Integer userId, String username, Date birthDate,Integer age, float fRate, char ch) SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd"); UserInfo user1 = new UserInfo(3, "bbb", ("1980-12-01"), 1, 1.2f, 'a'); UserInfo user2 = new UserInfo(0, "126", ("1900-10-11"), 03, -3.6f, 'c'); UserInfo user3 = new UserInfo(12, "5", ("1973-08-21"), 15, 9.32f, 'f'); UserInfo user4 = new UserInfo(465, "1567", ("2012-01-26"), 20, 12.56f, '0'); UserInfo user5 = new UserInfo(2006, "&4m", ("2010-05-08"), 100, 165.32f, '5'); UserInfo user6 = new UserInfo(5487, "hf67", ("2016-12-30"), 103, 56.32f, 'm'); UserInfo user7 = new UserInfo(5487,"jigg", ("2000-10-16"), 103, 56.32f, 'm'); UserInfo user8 = new UserInfo(5487, "jigg", ("1987-07-25"), 103, 56.32f, 'm'); (user1); (user2); (user3); (user4); (user5);

(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 list) { for (UserInfo user : list) { n(ng()); } }}


本文标签: 排序 升序 降序 倒序