配列のジェネリック型と非ジェネリック型の対応(ArrayList,HashTable,Queue,Stack)

ジェネリックジェネリックの対応一覧。

ジェネリック型は、Objectを操作する非ジェネリック型と違い、配列に格納する型(String,Integer・・etc)に合わせたタイプセーフな配列として定義できます。ArrayListとHashTableは名前が変わっているので要注意です。

ArrayList → List


ArrayList ar = new ArrayList();
List gar = new List();

■HashTable → Dictionary


Hashtable ht = new Hashtable();
Dictionary ght = new Dictionary();

■Queue → Queue


Queue q = new Queue();
Queue gq = new Queue();

■Stack → Stack


Stack s = new Stack();
Stack qs = new Stack();