Listing A
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Iterator;

public class Scheduler {
   
    private List todoList = new LinkedList();
   
    public long getTotalDuration() throws Exception {
       long total = 0L;
        for (Iterator i=todoList.iterator(); i.hasNext(); ) {
            total += ((Task)(i.next())).getDuration();
        }
        return total;
    }

    public void main(String[] args) {
        Scheduler s = new Scheduler();
        s.todoList.add(new DownloadTask("http://google.com"));
        try {
            System.out.println(s.getTotalDuration());
        } catch (Exception doh) {
            doh.printStackTrace();
        }
    }
}

interface Task {
    long getDuration() throws Exception;}

class DownloadTask implements Task {

    private String url;

    public DownloadTask(String u) {
        url = u;
    }
   
    public long getDuration() throws IOException {
        // this may throw an IOException
    }
}