- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java string concat() sample code examples.
You can concatenate two strings in Java either by using the concat() method or by using the ‘+’ , the “concatenation” operator.
The concat() method
The concat() method appends one String to the end of another. This 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 ConncatSample { public static void main(String []args) { String s1 = "Hello"; String s2 = "world"; String res = s1.concat(s2); System.out.print("Concatenation result:: "); System.out.println(res); } }
Output
Concatenation result:: Helloworld
- Related Articles
- Java string comparison sample code examples
- Java string case change sample code examples.
- C# String Concat with examples
- Java String concat() method
- Java regular expressions sample examples
- Java string concat() method vs "+" operator
- String Concatenation by concat() method.
- LongStream concat() method in Java
- DoubleStream concat() method in Java
- IntStream concat() method in Java
- Ints concat() function in Java
- Concat a string to SELECT * in MySQL?
- Java Program to convert ASCII code to String
- Obtain the hash code for a string in Java
- How do we add a sample computer code in HTML?

Advertisements