+ 1

How to concatenate two strings in Java?

Its a question on hackerrank and I am unable to do it

5th May 2019, 12:32 PM
rishabh tesla
rishabh tesla - avatar
20 Answers
0
Only imports are util,regex,text,math,io
5th May 2019, 2:20 PM
rishabh tesla
rishabh tesla - avatar
5th May 2019, 2:04 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 11
You can simply use the + operator or String's concat() method. Or use StringBuilder. You should add an example code to show where you're stuck if you need further information.
5th May 2019, 12:42 PM
Tashi N
Tashi N - avatar
+ 9
Bosnia & Herzegovina
6th May 2019, 1:10 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 8
Germany and I don't know how to get a job in the USA or UK. I guess the first step would be to apply for a job 🤔 But I think a feed post is better suited for such a survey rishabh tesla.
6th May 2019, 3:47 PM
Tashi N
Tashi N - avatar
+ 6
Mick Did you receive a message? Should be shown on the right of your notifs. If not you might need an update. I'll remove the off-topic posts in here..
7th May 2019, 8:19 PM
Tashi N
Tashi N - avatar
+ 4
rishabh tesla Germany. I would try to use the search bar (there are a lot of posts of how to get a job) and if you don't find enough information, post a new question.
6th May 2019, 9:45 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
rishabh tesla nextLine() reads the full line. Maybe your problem is a wrong way to input. Reading two strings using Scanner.nextLine(): First String [Enter] Second String Wrong: first String [space] second String
5th May 2019, 5:13 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
rishabh tesla Just test this in the code playground: Scanner scan = new Scanner(System.in); String one = scan.nextLine(); String two = scan.nextLine(); System.out.println(one + " " + two); Write each String in a separate line: Input: Hello, my name is ... Output: Hello, my name is ...
5th May 2019, 5:20 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Tashi N no, I didn't. I will update the app
7th May 2019, 8:23 PM
Михаил Сергеевич Давыдов
Михаил Сергеевич Давыдов - avatar
0
Actually its a question there are two string s and t s is given and t we have to input but its a big line so i have to read the string t and then concatenate it .i have tried the + operator .i think i am stuck in reading the string since string t is a long sentence
5th May 2019, 12:54 PM
rishabh tesla
rishabh tesla - avatar
0
For eg string s contains hackerrank and string t contains "is a good place for coding"
5th May 2019, 12:55 PM
rishabh tesla
rishabh tesla - avatar
0
Now i use the + operator but its only showing hackerrank since i use nextline method for reading string
5th May 2019, 12:56 PM
rishabh tesla
rishabh tesla - avatar
0
And i am unable to use readline method since the imports are default and cannot be changed
5th May 2019, 12:56 PM
rishabh tesla
rishabh tesla - avatar
0
Perhaps something like this snippet: String s = "Hackerrank "; Scanner in = new Scanner(System.in); String t = in.nextLine(); System.out.println(s + t);
5th May 2019, 2:04 PM
Dennis Colburn
Dennis Colburn - avatar
0
Dennis Colburn it is not taking the whole line ,theres a whole sentence with space
5th May 2019, 2:15 PM
rishabh tesla
rishabh tesla - avatar
0
How to read a full line
5th May 2019, 2:19 PM
rishabh tesla
rishabh tesla - avatar
6th May 2019, 12:44 PM
rishabh tesla
rishabh tesla - avatar
0
?
6th May 2019, 12:44 PM
rishabh tesla
rishabh tesla - avatar
0
How can i get a job in usa or uk ?
6th May 2019, 1:56 PM
rishabh tesla
rishabh tesla - avatar