Saturday, 12 September 2015

Java String compareTo

Java String compareTo


Java String concat

The java string concat() method combines specified string at the end of this string. It returns combined string. It is like appending another string.

Signature

The signature of string concat() method is given below:
  1. 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

  1. public class ConcatExample{  
  2. public static void main(String args[]){  
  3. String s1="java string";  
  4. s1.concat("is immutable");  
  5. System.out.println(s1);  
  6. s1=s1.concat(" is immutable so assign it explicitly");  
  7. System.out.println(s1);  
  8. }}  
Output
java string
java string is immutable so assign it explicitly

No comments:

Post a Comment