// package chapter7; /** * Title: Chapter 7, "Strings" * Description: Examples for Chapter 7 * Copyright: Copyright (c) 2000 * Company: Armstrong Atlantic State University * @author Y. Daniel Liang * @version 1.0 */ import java.util.StringTokenizer; public class TestStringTokenizer { /**Main method*/ public static void main(String[] args) { // Create a string and string tokenizer String s = "I am learning Java. Show me how to use StringTokenizer."; StringTokenizer st = new StringTokenizer(s); // Retrieve and display tokens System.out.println("The total number of words is " + st.countTokens()); while (st.hasMoreTokens()) System.out.println(st.nextToken()); } }