// Fig. 29.8: StringMiscellaneous2.java
// Métodos String replace, toLowerCase, toUpperCase, trim e toCharArray.

public class StringMiscellaneous2 
{
   public static void main( String args[] )
   {
      String s1 = new String( "hello" );
      String s2 = new String( "GOODBYE" );
      String s3 = new String( "   spaces   " );

      System.out.printf( "s1 = %s\ns2 = %s\ns3 = %s\n\n", s1, s2, s3 );

      // testa o método replace
      System.out.printf( 
         "Replace 'l' with 'L' in s1: %s\n\n", s1.replace( 'l', 'L' ));

      // testa o toLowerCase e toUpperCase
      System.out.printf( "s1.toUpperCase() = %s\n", s1.toUpperCase());
      System.out.printf( "s2.toLowerCase() = %s\n\n", s2.toLowerCase());

      // testa o método trim
      System.out.printf( "s3 after trim = \"%s\"\n\n", s3.trim());

      // testa o método toCharArray
      char charArray[] = s1.toCharArray();
      System.out.print( "s1 as a character array = " );

      for ( char character : charArray )
         System.out.print( character );

      System.out.println();
   } // fim de main
} // fim da classe StringMiscellaneous2 


/**************************************************************************
 * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 * Pearson Education, Inc. All Rights Reserved.                           *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 *************************************************************************/