Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 

Introduction to the Collections Framework
Magercises

By MageLang Institute

[Short Course| About This Short Course]

These Magercises illustrate how to use the essential capabilities of the Collection Framework. When you finish these Magercises, you will be able to effectively use the Map and Collection capabilities of the framework.

Magercise Outline

About Magercises

A Magercise is a flexible exercise that provides varying levels of help according to the student's needs. Some students may complete the magercise using only the information and the task list in the Magercise body; some may want a few hints (Help); while others may want a step-by-step guide to successful completion (Solution). Since complete solutions are provided in addition to help, students can skip a Magercise (or several) and still be able to complete later Magercises that required the skipped one(s).

The Anatomy of a Magercise

Each Magercise includes a list of any prerequisite Magercises, a list of skeleton code for you to start with, links to necessary API pages, and a text description of the Magercise's educational goal. In addition, buttons link you to the following information:
  • Help: Gives you help or hints on the current Magercise (an annotated solution). For ease of use, the task information is duplicated on the help page with the actual help information indented beneath it.
  • Solution: The <applet> tag and Java™ source resulting in the expected behavior.
  • API Documentation: A link directly to any necessary online API documentation.

Magercise Design Goals

There are three fundamental magercise types that you may encounter:
"Blank screen"
You are confronted with a "blank screen" and you create the entire desired functionality yourself.
Extension
You extend the functionality of an existing, correctly-working program.
Repair
You repair undesirable behavior in an existing program.

To make learning easier, Magercises, where possible, address only the specific technique being taught in that Magercise. Irrelevant, unrelated, and overly complex materials are avoided.

Where possible, Magercises execute via the web. However, Magercises that must access Java features or library elements that could cause security violations are not executed on the web.

Magercises, Introduction to the Collections Framework

  1. Using a HashSet for a Sparse Bit Set

    This Magercise has you extend the BitSet class to be a collection backed by a HashSet instead of an array of long values where individual bits are used to store the state of individual boolean values.

    Educational goal(s):

    • Extend the use of BitSet
    • Work with set algebra
    • Use a HashSet

  2. Using a TreeSet to provide a sorted JList

    This Magercise has you create a sorted data model for a JList, storing the data within an TreeSet.

    Educational goal(s):

    • Work with the SortedSet interface
    • Use a TreeSet
    • Use a Iterator

  3. Using an ArrayList with a JComboBox

    This Magercise has you create a mutable data model for a JComboBox, storing the data within an ArrayList.

    Educational goal(s):

    • Work with the List interface
    • Use a ArrayList

  4. Using a Map to Count Words

    This Magercise has you count the individual words in the contents specified by a URL. Then, you format the output for a JTextArea.

    Educational goal(s):

    • Work with the Map interface
    • Use a HashMap and TreeMap
    • Use a custom Comparator
    • Use the Map.Entry interface

Copyright © 1999 MageLang Institute. All Rights Reserved.


[ This page was updated: 29-Sep-99 ]

Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-99 Sun Microsystems, Inc.
All Rights Reserved. Legal Terms. Privacy Policy.