
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String Join Method in Java
The Join () method in strings concatenates all the elements of a string array, using the specified separator between each element.
In the below example we have a multi-line string and we have set the separator as “
” −
String.Join("
", starray);
Example
The following is the complete example −
using System; namespace StringApplication { class StringProg { static void Main(string[] args) { string[] starray = new string[]{"Down the way nights are dark", "And the sun shines daily on the mountaintop", "I took a trip on a sailing ship", "And when I reached Jamaica", "I made a stop"}; string str = String.Join("
", starray); Console.WriteLine(str); } } }
Output
Down the way nights are dark And the sun shines daily on the mountain top I took a trip on a sailing ship And when I reached Jamaica I made a stop
Advertisements