Strings | Sololearn: Learn to code for FREE!

+9

Strings

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

11/8/2018 3:17:06 PM

Googel

15 Answers

New Answer

+24

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 ?

+15

Why don't you try !? https://code.sololearn.com/cNm6ygciLbFi/?ref=app https://code.sololearn.com/cd9qdP4ts7F4/?ref=app https://code.sololearn.com/cpu2y8C1EZBN/?ref=app

+9

Try ThisOne!;) StringReverse -> lambda expression 👍😆 https://code.sololearn.com/c3px0cuKbvYS/?ref=app

+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.

+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.

+3

1. Use array 2. StringBuilder https://code.sololearn.com/cy26M72V2D2g/?ref=app https://code.sololearn.com/cpAv2CZejx67/?ref=app

+1

Im understand

0

[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".

0

Hi I have problem in this

0

how do you write a string in a double quote

0

What is the difference between interpreter and shell programming?? I'm new🤗

0

https://code.sololearn.com/WpHILLhwf60c/?ref=app

0

https://code.sololearn.com/cWQjYRTQs98Q/?ref=app You can use this ... Thanks!!

-1

-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