Comparable方法中的compare方法的返回值(1,-1,0)判断升序还是降序?

判断升序还是降序
return this.count > o.count ? -1 : 1; 降序排列 等价于 return o.count - this.count
return this.count > o.count ? 1 : -1; 升序排列 等价于 return this.count - o.count
相等是0
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_46548855/article/details/108176177