go to previous page   go to home page   go to next page

Answer:

No — that is one of the advantages of using StringBuffer.


Palindrome Detector

A palindrome is a string that reads the same when it is reversed. Punctuation, spaces, and capitalization are ignored. For example, the following is a palindrome:

Eva, Can I Stab Bats In A Cave?

Let us write a program that determines if a string is a palindrome. In this program, the string is hard-coded in the program as a String object.


class Tester
{
  public boolean test( String trial )
  {
    . . . .
  }
}

public class PalindromeTester
{
  public static void main ( String[] args )
  {
    Tester pTester = new Tester();
    String trial = "Eva, Can I Stab Bats In A Cave?" ;
    if ( pTester.test( trial ) )
      System.out.println( "Is a Palindrome" );
    else
      System.out.println( "Not a Palindrome" );
  }
}

QUESTION 9:

Class String has a method toLowerCase() and a method toUpperCase(). Will these methods be useful?


go to previous page   go to home page   go to next page