teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

コードの間違いを訂正

2017/06/20 05:08

投稿

KSwordOfHaste
KSwordOfHaste

スコア18404

answer CHANGED
@@ -18,12 +18,14 @@
18
18
 
19
19
  Comparator<TestTableData> comparator = new Comparator<>() {
20
20
  @Override
21
- public int compareTo(TestTableData that) {
21
+ public int compare(TestTabledata a, TestTableData b) {
22
- return -(getBInt() - that.getBInt()); // 整数の自然順序(昇順)の逆
22
+ return -(a.getBInt() - b.getBInt()); // 整数の自然順序(昇順)の逆
23
23
  }
24
24
  };
25
+ //訂正:下の方の実装例を間違えて書いてましたのでコードを訂正しまた。失礼しました。
25
26
  ```
26
27
 
28
+
27
29
  さて実際のソートはFXCollectionにObservableListをソートできる便利メソッドがありますので前述のComparatorを使うと以下のように書けます。
28
30
 
29
31
  ```Java