Stop show with sound -- Keyboard shortcut: 'x'  Next slide in show -- Keyboard shortcut: 'n'  3 minutes, 43 secondsCollections og streams - slide 13 : 35

Et eksempel på anvendelse af List 

import java.util.*;
import java.io.*;

class ListDemo {

 static List store = new ArrayList();
 
 /** Insert element in v, such that v remains sorted */
 static void insert(String element, List lst){
  int i = 0;
  while (i < lst.size() && 
         ((String)lst.get(i)).compareTo(element) < 0
        )
    i = i + 1;
 
  lst.add(i,element);
 }
 
 
 public static void main(String[] args) throws IOException {
   BufferedReader stdin = 
      new BufferedReader (new InputStreamReader (System.in));
   String str;
   do{
     System.out.println("Type a string to be inserted " +
                        "(empty string terminates): ");
     str = stdin.readLine();  
     if (str.length() > 0){
       insert(str,store);
       System.out.println(store);
      }
     } while (str.length() > 0);
 }
}