Method for realizing reverse order output of words in English sentences by Java
This paper gives an example of how Java can output words in reverse order in English sentences. Share with you for your reference, as follows:
Title Requirements: given n lines of English sentences, it is required to output the sentences after the words in reverse order in the sentences, such as:
Input: n = 3 I love you how are you my name is lining
Output:
you love I you are How Liming is name My
According to the method (split ("")) provided by the Java language for us to split words with space intervals, we can output them in reverse order;
Implementation code:
Operation results:
Readers interested in more Java related content can view the special topics of this site: summary of Java character and string operation skills, summary of Java array operation skills, summary of Java mathematical operation skills, tutorial on Java data structure and algorithm and summary of Java operation DOM node skills