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.
List <String> list = new ArrayList<String>(); list.trimToSize();
インターフェイスではなく、にtrimToSize()のみ表示されるので、具象クラスの代わりにインスタンス化すると、これは失われる機能の1つですか?ArrayListListinterface
trimToSize()
ArrayList
List
interface
呼び出すタイプによって提供されるメソッドのみを呼び出すことができます。メソッドを呼び出しtrimToSize( )たい場合は、最初に次の場所にキャストlistする必要がありArrayListます。
trimToSize( )
list
( (ArrayList) list ).trimToSize( );