Follow on Facebook

Like and Share on Facebook

Saturday, January 24, 2015

Java String concat


Java String concat

The java string concat() method combines specified string at the end of this string.

Signature

The signature of string concat() method is given below:

public String concat(String anotherString)

Parameter

anotherString : another string i.e. to be combined at the end of this string.

Returns

combined string

Java String concat() method example

public class ConcatExample{  
public static void main(String args[]){  
String s1="java string";  
s1.concat("is immutable");  
System.out.println(s1);  
s1=s1.concat(" is immutable so assign it explicitly");  
System.out.println(s1);  
}}  

Output:
java string
java string is immutable so assign it explicitly

No comments:

Post a Comment