Share on Google+Share on Google+

Concatenate Two Strings in java

Advertisement
Summary : We are going to describe how to concatenate of two string. we have use for concat() method, this method joints of two string first-to-end.

Concatenate Two Strings in java

We are going to describe how to concatenate of two string. we have use for concat() method, this method joints of two string first-to-end.

Description of below example:-

In this below example we have taken two String string and string2.This keyword returns of String followed by String arguments Characters. After that we have use string.concat(string2) method it means add the two String first-to-end. You can  use anther  way method "+" operator you can easily add of first-to-end string.

There are two method add of String:-

  • String string3 = string + " "string;
  • String string3 = string.concat(string2);

Example

package StringExample;


 public class TwoStringConcatenate {
	public static void main(String[] args) {
		String string ="rose india";
		
		String string2="technologies pvt limited";
		
		String string3 = string.concat(string2);
		//Another way Add of two String
		
		/*
		 
		  String string3=string + ""+string2;
		 
		  */
		
		
		System.out.println("Concatenated string: " + string3);
	}
	
}

Output

Download Source Code

Advertisements

Advertisement

Posted on: August 8, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Concatenate Two Strings in java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0