The Collections Framework tkorinphotmail com The Collections Framework

  • Slides: 14
Download presentation
The Collections Framework �������� ������������� (tkorinp@hotmail. com)

The Collections Framework �������� ������������� (tkorinp@hotmail. com)

The Collections Framework • • • An Introduction to Collections 2) Collection Interfaces 3)

The Collections Framework • • • An Introduction to Collections 2) Collection Interfaces 3) Old and New Collections 4) Lists 5) Sets 6) Maps 7) Collection Implementations 8) Overview of the Collections Framework 9) An Example Using Un-typed Collections 10) An Example Using Typed Collections 11) A Note About Sets 12) Summary

Overview of the Collections Framework

Overview of the Collections Framework

An Example Using Un-typed Collections • Iterator ���� Interface ���������� Collection ������ Set ����

An Example Using Un-typed Collections • Iterator ���� Interface ���������� Collection ������ Set ���� � public void display() public void append. String(String import java. util. List; ����� method ����� has. Next } p. Str) import java. util. Array. List; String next. Item; } import java. util. Iterator; Iterator it = m. AList. add(p. Str); public class List. Demo ��� , next remove m. AList. iterator(); { } List m. AList; **/ * Constructor /* public List. Demo () } m. AList = new Array. List(); { public void insert. String(int p. Pos, String p. Str) } m. AList. add(p. Pos, p. Str); { public void delete. String(int p. Pos) } m. AList. remove(p. Pos); { while (it. has. Next()) } next. Item = (String)it. next(); System. out. print(next. Item + " "); { System. out. println(); {

An Example Using Typed Collections • ������ 2 ����������� • (1 ������������������ import java.

An Example Using Typed Collections • ������ 2 ����������� • (1 ������������������ import java. util. List; � ����������� import java. util. Array. List; public������� class List. Demo. Loop } • (2����� Java 5. 0 private List<String> m. AList; �� ������������ public List. Demo () } • Generic Typesm. AList = new Array. List<String>(); { public void display() } for (String next. Item : m. AList) } System. out. print(next. Item + " "); { System. out. println(); { {