![]() |
VOOZH | about |
The concat() method in Java is used to append one string to another and returns a new combined string. It does not modify the original string since strings are immutable.
GeeksforGeeks
public String concat (String s);
There are many ways to use the concat() method in Java:
Example: Combining Two Strings with concat() Method
GeeksforGeeks
Example: Sequential Concatenation of Multiple Strings
Computer-Science- Computer-Science-Portal
Note: Strings are immutable in Java, so every concatenation creates a new string object instead of modifying the existing one.
Example: Handling NullPointerException in String concat()
Output
Exception in thread "main" java.lang.NullPointerExceptionExample: Reversing a String Using concat() Method
Geeks skeeG