Strings | Sololearn: Learn to code for FREE!



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

11/8/2018 3:17:06 PM


15 Answers

New Answer


1)take the input directly into a String array String input[]=new Scanner(" "); 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 ?


Why don't you try !?


Try ThisOne!;) StringReverse -> lambda expression 👍😆


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.


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.


1. Use array 2. StringBuilder


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


Hi I have problem in this


how do you write a string in a double quote


Im understand


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


0 You can use this ... Thanks!!



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