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.
型情報が消去のために実行時に利用できない場合、Java コンパイラはジェネリック コレクション内のオブジェクトに適切なキャストを提供することをどのように認識しますか?
eg を呼び出すたびにlist.get(foo)、リストが anArrayList<String>の場合、 の結果は呼び出し先ではなく呼び出し元によってgeta にキャストされます。呼び出し元はコンパイル時に結果を何にキャストするか (a ) を知っているので、そこにキャストを挿入できます。StringString
list.get(foo)
ArrayList<String>
get
String