Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My code:
String o = "56";
String hello = "Rudra";

What I have tried:

Why it says:
56Rudra but not 56 Rudra
Updated 21-Jul-23 2:29am

Because you are concatenating "56" o with "Rudra" hello - you have not included any spaces

In fact - look at the solution to your earlier question How to add space between this output?[^]
Share this answer
Rudra 2023 21-Jul-23 7:28am    
I have used the concat method to add spaces only.
Richard Deeming 21-Jul-23 7:38am    
The concat method concatenates two strings. It does NOT add any space or extra characters between the two strings.
Instead of posting the same basic question again, your time would be better spent actually learning the language. Go to Java Tutorials Learning Paths[^], where everything is clearly explained.
Share this answer
Hint: read the documentation String (Java Platform SE 8 )[^].
Share this answer
Graeme_Grant 21-Jul-23 7:34am    
Class is out
To add to the other's answers, Java includes a join method that can concatenate any number of strings with a separator string between each:
System.out.println(String.join(" ", "Hello", "World"));

Hello World
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900