CHAPTER 49D — StringBuffer Objects

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to home page   go to next page

created: 05/08/00; Revised: 07/22/02, 06/02/03, 02/20/06

CHAPTER 49D — StringBuffer Objects

This chapter discusses the StringBuffer class, which is useful for processing character data. The class String alone could be used for this, but the StringBuffer class is often faster and more convenient.

Chapter Topics:

  • Immutable Strings
  • charAt() method of String
  • Reversing a string
  • StringBuffer
  • Palindromes

Although the StringBuffer class is sometimes very useful, it is not essential. It is not covered in the AP Java computer science test.

QUESTION 1:

(Review: ) Examine the following code:

String data = new String("Turtle");

data = data + 's' ;

Does the last statement construct a new String?