DESKTOP-7HC873M_20200831-李宗宝
问题
自然比较方法
int compareTo( T another )
public int compareTo(Phoenix another) {
if (this.age < another.age) {
return -1;
} else if (this.age == another.age) {
return 0;
} else {
return 1;
}
}
通过比较Phoenix中的年龄,然后返回负整数,零,或正整数
然后再通过 Arrays.sort(phoenix);对 phoenix 进行排序。
public int length() {
return count ;//返回缓冲区中字符的个数
}
public int capacity() {
return buffer.length ;//返回字符缓冲区的长度
}
心得
每周一,必瞌睡,没办法
点赞