JRJC - How To Concat Strings

You can concat two strings together to make one new string by using the plus sign ("+").

Suppose you have a string s that contains "Gertrude", like this:


    String s = "Gertrude";

To send a greeting, you might use concatenation like this:

    System.out.println( "Hello " + s + "!  How are you today?" );

and see

    Hello Gertrude!  How are you today?

For more information on string concatenation, see page 99 of Just Java 1.2. or page 61-62 of Just Java 2 (sixth edition).




© 2000 Paul Wheaton