![how to do reverse words in word how to do reverse words in word](https://i.ytimg.com/vi/TZMAZVaTgzw/maxresdefault.jpg)
This will reverse your ArrayList and you will have all the words in reverse order, now all you need to do is concatenate multiple String by iterating over ArrayList. Once you got the array, you can create an ArrayList from an array, and then you are eligible to use Collections.reverse() method. It will also handle words separated by multiple spaces, so you don't need to worry. Once you split the String using regex "\\s", it will return you an array of words. I highly recommend this course to every Java programmer who wants to improve his data structure skills. One more important question for the Interviewer is about spacing between words, is it possible to have multiple spaces between two words? Yes, it could be possible but you can reduce them to a single space in the reversed string.ītw, if you preparing for a programming job interview, you can also take a look at the Data Structures and Algorithms: Deep Dive Using Java, you will not only find some good question on array and String but also its a good refresher course to revise and clear concept on essential data structure for Java programmers. However, your reversed string should not any contain leading or trailing spaces. Another good question you can ask to Interview is about input like is it possible for input string to contain leading or trailing spaces? One question the candidate should definitely ask is, what constitutes a word here? For the purpose of this program, the word is nothing but a sequence of non-space characters. Also asking a question not only fill the gaps in requirement but also help you to make an impression. Never assume you know everything, even if it looks like a simple problem.
![how to do reverse words in word how to do reverse words in word](https://i.pinimg.com/736x/2e/c0/85/2ec0859b99a7a200e8128a27dfccd289--reverse-text-craft-things.jpg)
Now, if you are a good programmer then you should have some right questions for the Interviewer. Your program must produce a String that contains the word in reverse order, for example, if the given input is "Java is Great" then your program should return "Great is Java". A String is nothing but a sentence, which may contain multiple works, or just contain a single word or it may be empty.
#How to do reverse words in word how to#
It's also one of the popular coding questions, so you will also learn how to take a requirement, how to fill gaps in the requirement by asking the right question. Earlier, I have shared 75 Programming interview questions and In this Java Coding tutorial, you will learn how to reverse words in String. Hello guys, if you are wondering how to reverse words in a given String in Java then you have come to the right place.