21.11.2014 Views

PJWSTK - MAS - Wykład 05

PJWSTK - MAS - Wykład 05

PJWSTK - MAS - Wykład 05

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Java Generics (2)<br />

o<br />

Rozwiązanie: klasy parametryzowane (generics)<br />

private void testCollection() {<br />

List list = new ArrayList();<br />

list.add(new String("Hello world!"));<br />

list.add(new String("Good bye!"));<br />

list.add(new Integer(95));<br />

printCollection(list);<br />

}<br />

private void printCollection(Collection c) {<br />

Iterator i = c.iterator();<br />

while(i.hasNext()) {<br />

String item = i.next();<br />

System.out.println("Item: "+item);<br />

}<br />

}<br />

Modelowanie i Analiza Systemów Informacyjnych (<strong>MAS</strong>), wykład 3 14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!