Java String concat() method

Java 8Object Oriented ProgrammingProgramming

The concat() method of the String class appends one String to the end of another. The method returns a String with the value of the String passed into the method, appended to the end of the String, used to invoke this method.

Example

public class Test {
   public static void main(String args[]) {
      String s = "Strings are immutable";
      s = s.concat(" all the time");
      System.out.println(s);
   }
}

Output

Strings are immutable all the time
raja
Published on 09-Feb-2018 15:04:38
Advertisements