How do you join strings in java?



How do you join strings in java?..

Answer / Rahul Vaish

To join strings in Java, you can use the + operator or concatenation method (String.join()). Using the + operator: `String str1 = "Hello"; String str2 = "World"; String result = str1 + ' ' + str2;`. Using String.join(): `List<String> list = Arrays.asList("Hello", "World"); String result = String.join(" ", list);`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

When would you use a static class?

1 Answers  


How is rounding performed under integer division?

2 Answers   Satyam,


What type of language is java?

1 Answers  


Which Math method is used to calculate the absolute value of a number?

3 Answers   Accenture,


Does google use java?

1 Answers  


Explain the difference between map and flatmap stream operation?

1 Answers  


Accenture NJ mostly ask question on Collection like 1)How to sort Objcts and how treeset sort them 2)Explain mechanism of Hashcode finding in Java 3)Name some of the Sorted collection.

2 Answers   Accenture,


Is java se open source?

1 Answers  


how to write a server program and sending the mails to the server using smtp protocol please help me

1 Answers   Lampex,


What is basic syntax?

1 Answers  


Explain, java is compatible with all servers but not all browsers?

1 Answers  


How many ways can an argument be passed to a subroutine and explain them?

1 Answers  


Categories