Source of StringConcatenation.java


  1: // Fig. 29.7: StringConcatenation.java
  2: // String concat method.
  3: 
  4: public class StringConcatenation 
  5: {
  6:    public static void main( String args[] )
  7:    {
  8:       String s1 = new String( "Happy " );
  9:       String s2 = new String( "Birthday" );
 10: 
 11:       System.out.printf( "s1 = %s\ns2 = %s\n\n",s1, s2 );
 12:       System.out.printf( 
 13:          "Result of s1.concat( s2 ) = %s\n", s1.concat( s2 ) );
 14:       System.out.printf( "s1 after concatenation = %s\n", s1 );
 15:    } // end main
 16: } // end class StringConcatenation
 17: 
 18: /**************************************************************************
 19:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 20:  * Pearson Education, Inc. All Rights Reserved.                           *
 21:  *                                                                        *
 22:  * DISCLAIMER: The authors and publisher of this book have used their     *
 23:  * best efforts in preparing the book. These efforts include the          *
 24:  * development, research, and testing of the theories and programs        *
 25:  * to determine their effectiveness. The authors and publisher make       *
 26:  * no warranty of any kind, expressed or implied, with regard to these    *
 27:  * programs or to the documentation contained in these books. The authors *
 28:  * and publisher shall not be liable in any event for incidental or       *
 29:  * consequential damages in connection with, or arising out of, the       *
 30:  * furnishing, performance, or use of these programs.                     *
 31:  *************************************************************************/