First page Back Continue Last page Graphics
Java Generic Data Structures and Coercion (cont'd)
Ramifications:
- You cannot directly assign an element of one of these collections to a variable unless it is declared to have type Object
- Most likely you will want to coerce the returned value to a more appropriate specific type
For example, if s is an object of type Stack that holds strings then when you pop this stack you will want to coerce the result to String: