3. Introduction
mfarra.cst.ps www.fb.com/MahmoudRFarra
You can create an array to store objects. But, once
the array is created, its size is fixed.
Nevertheless, you can still use arrays to implement
dynamic data structures.
The trick is to create a larger new array to replace
the current array, if the current array cannot hold new
elements in the list.
5. The ArrayList Class
mfarra.cst.ps www.fb.com/MahmoudRFarra
Java provides the ArrayList class, which can be used to
store an unlimited number of objects.
ArrayList is known as a generic class with a generic type E.
You can specify a concrete type to replace E when creating
an ArrayList.
For example:
ArrayList <String> cities = new ArrayList<> ();
10. Array List
mfarra.cst.ps www.fb.com/MahmoudRFarra
The ArrayList is in the java.util package, it is imported in line 1.
Case Study: Develop a program that prompts the user to enter a
sequence of numbers and displays the distinct numbers in the
sequence. Assume that the input ends with 0 and 0 is not counted
as a number in the sequence. [ind, N.W]
11. using Java
2015
FB: M a h m o u d R F a r r a
YouTube: M a h m o u d R F a r
SlidesShare: mralfarra
Thank you