Lists & Iterators
- The preceding structure is simply a
LinkedList
that is already defined in Java in the java.util
package.
This class implements
the List
interface that has other possible implementations:
- ArrayList,
- Vector (usefull in multithreading),
- Stack, etc.
So, an application can simply use any list, in design phase, then choose the implementation adapted to the target platform:
public static void main(String[] args) {
List<String> orders = new LinkedList<String>(); // memory optimization
// orders = new ArrayList<String>(); // computations optimization
orders.add("Chicken"); orders.add("French Fries"); orders.add("Salad");
System.out.println(orders);
}
As a remark, the "orders" type can be explicitly defined by:
public class TOrder extends ArrayList<Item> { ... }
5 - 13Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented