Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は を持っており、Set<Integer>そのためのいくつかのユーティリティ メソッドを作成したい (つまり、最大値、最小値などを取得する)。静的メソッド (つまりint SetUtils.getMax(Set<Integer> inputSet)) を持つユーティリティ クラスを持つ方が良いですか、または Set の実装を拡張するクラス (つまりclass IntegerSet extends HashSet) ?
Set<Integer>
int SetUtils.getMax(Set<Integer> inputSet)
class IntegerSet extends HashSet
ユーティリティ クラスはより柔軟です。インターフェイスの任意の実装で機能するユーティリティ メソッドを提供できSetます。追加のメソッドを使用して の独自のサブクラスを作成する場合HashSet、特定のサブクラスのインスタンスでのみそれらの追加のメソッドを呼び出すことができます。
Set
HashSet