String method concat. - Java Language Basics

Java examples for Language Basics:String

Description

String method concat.

Demo Code

public class Main 
{
   public static void main(String[] args)
   {/*from   www .j a  v a 2 s  . c  om*/
      String s1 = "Happy ";
      String s2 = "Birthday";

      System.out.printf("s1 = %s\ns2 = %s\n\n",s1, s2);
      System.out.printf(
         "Result of s1.concat(s2) = %s\n", s1.concat(s2));
      System.out.printf("s1 after concatenation = %s\n", s1);
   } 
}

Result


Related Tutorials