![]() |
Working With Strings
PrerequisitesStrings in java, like arrays, are first-class objects. This Magercise demonstrates some common manipulations with Strings and StringBuffers.StringBuffers are similar to Strings, but they can be modified using methods like append and prepend. As with the array Magercise, each task can be done incrementally, by adding its code to the Scrapbook and running it after it's written. As with arrays, some String operations can raise exceptions. Strings are discussed in detail in the course notes. Tasks
Perform the following tasks:
Print out a substring of the "hello world" string. Create another "Hello World" string using a StringBuffer and its append method. Print it to System.out. Use concatenation to convert some integers and floating point numbers to a string for printing. As in the notes, use Integer.parseInt to convert a String into an Integer, then print it to System.out.
|
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |