PDF Photo credit: Andrew Kennedy GENERICS AND THE JAVA ...
Photo credit: Andrew Kennedy
GENERICS AND THE JAVA COLLECTIONS FRAMEWORK
Lecture 16 CS2110 ? Fall 2015
Textbook and Homework
2
Generics: Appendix B Generic types we discussed: Chapters 1-3, 15 Useful tutorial: docs.javase/tutorial/extra/generics/index.html
Java Collections
3
Early versions of Java lacked generics...
interface Collection { /* Return true if the collection contains o */ boolean contains(Object o);
/* Add o to the collection; return true if *the collection is changed. */
boolean add(Object o);
/* Remove o fromthe collection; return true if * the collection is changed. */
boolean remove(Object o); ... }
Java Collections
4
The lack of generics was painful when using collections, because programmers had to insert manual casts into their code...
Collection c = ... c.add("Hello") c.add("World"); ... for (Object o : c) {
String s = (String) o; System.out.println(s.length + " : " + s.length()); }
Using Java Collections
5
This limitation was especially awkward because builtin arrays do not have the same problem!
String [] a = ... a[0] = ("Hello") a[1] = ("World"); ... for (String s : a) {
System.out.println(s); }
So, in the late 1990s Sun Microsystems initiated a design process to add generics to the language...
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- pdf standard template library and the java collections classes
- pdf learning computer programming using java with 101 examples
- pdf lambda expressions in java 8 part 1 basics
- pdf java current affairs 2018 apache commons collections
- pdf 15 department of computer science
- pdf java collections framework
- pdf java basics usf computer science
- pdf introduction to programming using java iit kanpur
- pdf java in a nutshell 6th edition covers java 8 r 5
- pdf photo credit andrew kennedy generics and the java
Related searches
- the government and the economy
- the java programming language pdf
- the torah and the talmud
- explain the new and the old testament
- inputs and outputs java coding examples
- find the center and the radius calculator
- the sun and the earth
- find the center and the radius
- the mommas and the poppas
- happiness is the meaning and the purpose of life the whole aim and end of human
- the earth and the sun
- jesus and the woman at the well