Computer Science 212

Project 1 hints

Copyright © 2005 by Dorothy L. Nixon. All rights reserved.



Table of contents

  1. The compareTo method of class String
  2. Using a StringTokenizer
  3. Displaying a large amount of text to a JOptionPane dialog box



Example files (download as ZIP file here)

The example files may be downloaded in a ZIP file here.


Project 1 hints


  1. The compareTo method of class String
  2. If you have not done so already, read the section of Tutorial 2 on how to use the Sun Java documentation.

    In the Sun Java documentation for the java.lang package, look up the String class and read the description of the compareTo and compareToIgnoreCase methods. Below is a simple example program using the compareTo method:

    The compareTo method can be used when sorting strings.


  3. Using a StringTokenizer
  4. In the Sun Java documentation for the java.util package, look up the StringTokenizer class. Below are some simple example programs using StringTokenizer objects:

    The above programs use objects of the following classes for text file I/O:

    The example program StringTokenizerDemo3.java uses a StringTokenizer in a manner somewhat similar to the way you'll be using it in the project. Note the use of the two-parameter constructor to create the StringTokenizer object.


  5. Displaying a large amount of text to a JOptionPane dialog box
  6. The example programs below are variants of example programs for Tutorial 2 and Tutorial 3. The following programs display text to a text area (class JTextArea) on a JOptionPane message dialog box.



Computer Science 212:  main page