- 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
Different ways to concatenate Strings in Java
You can concatenate two strings in Java either by using the concat() method or by using the ‘+’ , the “concatenation” operator.
Example
public class ConncatSample { public static void main(String []args) { String s1 = "Hello"; String s2 = "world"; String res1 = s1.concat(s2); String res2 = s1+s2; System.out.print("Concatenation using method:: "); System.out.println(res1); System.out.print("Concatenation using operator:: "); System.out.println(res2); } }
Output
Concatenation using method:: Helloworld Concatenation using operator:: Helloworld
- Related Articles
- In how many ways we can concatenate Strings in Java?
- Concatenate Multiple Strings in Java.
- The Optimum Method to Concatenate Strings in Java.
- How to concatenate two strings using Java?
- Ways to concatenate tuples in Python
- Different ways to create Objects in Java
- How to concatenate strings in R?
- Concatenate strings in Arduino
- Are there any ways to Manipulate Strings in Java.
- 5 different ways to create objects in Java
- Different ways to overload a method in Java
- Different ways to print exception messages in Java
- Different ways to create an object in java?
- Different ways to traverse an Array in Java?
- How to concatenate several strings in JavaScript?

Advertisements