javacodex.com
Java Examples
Java Examples
memu home questions

Concatenating Strings

This java program example demonstrates how to concatenate two strings.

Source: (ConcatStrings.java)

public class ConcatStrings {
   public static void main(String[] args) {
      String s1 = "abcdefghijkljkl";
      String s2 = "mnopqrstuvwxyz";
      String s3 = s1 + s2;
      System.out.println("s1: " + s1);
      System.out.println("s2: " + s2);
      System.out.println("s3: " + s3);
   }
}
 

Output:

# java ConcatStrings 
s1: abcdefghijkljkl
s2: mnopqrstuvwxyz
s3: abcdefghijkljklmnopqrstuvwxyz

Contact: javacodex@yahoo.com