hcdy.net
当前位置:首页 >> JAvA CollECtions.sort 匿名内部类问题 >>

JAvA CollECtions.sort 匿名内部类问题

语法错误的话 是这里少了个括号 new Comparator() { Collections.sort(emps, new Comparator() { public int compare(Empp o1, Empp o2) { return (int) o1.getSalary() - o2.getSalary(); }});

import java.util.Arrays;import java.util.Comparator;public class YuGiOh{public static void main ( String[] args ){String[] strs = { "qwe", "asfa", "qfwagaa", "rfbu", "a", "hlelllp" };Arrays.sort (strs, new Comparator (){@Overri...

网站首页 | 网站地图
All rights reserved Powered by www.hcdy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com