+ 12

Strings

How do you reverse words in a given sentence without using any library method?

8th Nov 2018, 3:17 PM
Googel
Googel - avatar
15 Respostas
+ 27
1)take the input directly into a String array String input[]=new Scanner(System.in).nextLine().split(" "); 2)now make a method to take String values as parameter & return reversed String . 3)run the loop through that input array [System.out.print(method (word));] //many other approaches are also possible , though its what comed in my mind after seeing this question , hope it helps☺ //want to know more about split() method & more such stuff ?
8th Nov 2018, 5:10 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 10
Try ThisOne!;) StringReverse -> lambda expression 👍😆 https://code.sololearn.com/c3px0cuKbvYS/?ref=app
9th Nov 2018, 9:43 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 8
Here's a pseudo code using for loop... Initialize a new empty string called Str which = "" FOR character "Ch" till the END of the string : Str = Ch + Str Str saves the the reverse of the given string.
8th Nov 2018, 5:25 PM
Aaron Stone
Aaron Stone - avatar
+ 5
You can do with auxiliary string. Just initialize a empty string with same length of word and make a for-each (word) with an auxiliary count that start in index of last position and just store in the empty array in reverser order. If you do this method you don't lose original input.
8th Nov 2018, 3:38 PM
Anya
Anya - avatar
9th Nov 2018, 1:20 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 1
[Ans: ✓ \"] >>>"\"" " Type "\"" in the blank and click Check you will get reply as correct with a bell sound. Reason: Some characters can't be directly included in a string. For instance, double quotes can't be directly included in a double quote string; this would cause it to end prematurely. Characters like these must be escaped by placing a "backslash"[ \ ] before them. Other common characters that must be escaped are newlines and "backslashes". Double quotes only need to be escaped in double quote strings, and the same is true for single quote strings. Example: >>> 'Brian\'s mother: He\'s not the Messiah. He\'s a very naughty boy!' 'Brian's mother: He's not the Messiah. He's a very naughty boy!' Note: [ \n represents a new line ] "Backslashes" can also be used to "escape tabs", "arbitrary Unicode characters", and various other things that can't be reliably printed. These characters are known as "escape characters".
1st Jul 2020, 8:46 AM
Chintu
0
Hi I have problem in this
19th Sep 2020, 11:52 AM
Sandesh Naik
Sandesh Naik - avatar
0
how do you write a string in a double quote
5th Oct 2020, 8:36 PM
ttvclvckpwner
ttvclvckpwner - avatar
0
Im understand
22nd Nov 2020, 10:54 AM
котяра
котяра - avatar
0
What is the difference between interpreter and shell programming?? I'm new🤗
24th Nov 2020, 4:29 AM
K T
K T - avatar
22nd Apr 2021, 4:31 AM
Afsar Khan
Afsar Khan - avatar
0
https://code.sololearn.com/cWQjYRTQs98Q/?ref=app You can use this ... Thanks!!
31st Jul 2021, 5:01 PM
kreddyt
kreddyt - avatar
- 1
It is bad
9th Nov 2018, 12:07 PM
Александр Михайлов
Александр Михайлов - avatar
- 1
For reverse a word i would use a variable type char and create a method using the switch conditioner. We could add an array and join the loops for. With these resource you can use your imagine and improve yourself your skilla until you get your target program
26th Jun 2020, 1:40 AM
Orlando Bidó Gerónimo
Orlando Bidó Gerónimo - avatar