Monday, 12 August 2013

How To Concatenate Two Strings

Concatenation means to join two or more words or text strings together. There are two ways to concatenate string objects:


  • By + (string concatenation) operator.
  • By concat() method.


WAP to concatenate two strings

class concatenate{
public static void main(String args[])
{
String s=" Maninder"+" Singh";       //Using + operator
String s1="Hello";
System.out.println(s+"\n");

System.out.println(s1.concat(s));     //Using concat() function

}
}

Output of the program:

Concatenate string


Like the Post? Do share with your Friends.

No comments:

Post a Comment

IconIconIconFollow Me on Pinterest

Blogger news

Blogroll

What's Hot