containing ArrayLists - 2 Constrained ArrayLists a1 Integer...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS101J, Cornel 0 Constrained ArrayLists a0 ArrayList 0 a1 1 a4 2 a2 a1 String CS100M a4 Integer 5 a2 JFrame Each object is of class Object —the apparent class of each element is Object. Object Object Object CS101J, Cornel 1 Constrained ArrayLists a1 Integer 0 a4 Integer 7 a2 Integer -5 a0 ArrayList 0 a1 1 a4 2 a2 Integer Integer Integer b= new ArrayList<Integer>(); b a0 A call b.add(x) in which x is not of class Integer (or one of its subclasses) is illegal) CS101J, Cornel
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2 Constrained ArrayLists a1 Integer a4 Integer 7 a2 Integer-5 a0 ArrayList a1 1 a4 2 a2 Integer Integer Integer b= new ArrayList&lt;Integer&gt;(); b a0 A call b.add(x) in which x is not of class Integer (or one of its subclasses) is illegal) Using a constrained ArrayList reduces the chance of making an error by adding something to a list that does not belong there....
View Full Document

Ask a homework question - tutors are online