reverse a string in java word by word

Solutions on MaxInterview for reverse a string in java word by word by the best coders in the world

showing results for - "reverse a string in java word by word"
Lisa
15 Mar 2016
1// Reverse a string in java word by word
2import java.util.Scanner;
3public class ReverseStringWordByWord 
4{
5   public static void main(String[] args) 
6   {
7      String strWord = "";
8      Scanner sc = new Scanner(System.in);
9      System.out.println("Please enter a string: ");
10      String strGiven = sc.nextLine();     
11      char[] chArray = strGiven.toCharArray();
12      System.out.println("Reversed string word by word: ");
13      for(int a = 0; a < (chArray.length); a++)
14      {
15         if(chArray[a] != ' ')
16         {
17            strWord = strWord + chArray[a];
18         }
19         else
20         {
21            for(int b = strWord.length(); b > 0; b--)
22            {
23               System.out.println(strWord.charAt(b - 1));       
24            }
25            System.out.print(" ");
26            strWord = "";
27         }
28      }
29      for(int b = strWord.length(); b > 0; b--)
30      {
31         System.out.println(strWord.charAt(b - 1));       
32      }
33      sc.close();
34   }
35}
queries leading to this page
java program to reverse every word in a stringwap in java to reverse a string by word how to reverse a string word by word in javareverse each word in a string in javastring reverse word by word in javahow to reverse a word in javareverse java string wordreverse a string word by word in javahow to reverse word in javaword reverse in javareverse word in javaprogram to reverse every word in a string and reverse the string javahow to write a word backwards in javareverse a string in java word by word in javareverse string of words in javareverse word for javawrite a function to reverse a string word wise in javastring reverse by words in javareverse words in a string in javareverse a word java method how to reverse word by word in javareverse a string words by word using recursion javajava reverse every word in your stringjava reverse string wordsreverse each word in a given string in javainverse word order in string javareverse words in a given string in javahow to make a word backwards javareverse word in a give sentence in javagiven a string reverse each word in the sentence in javareverse individual words in a string javareverse each word in string in javareverse each word in a string javajava what is reversed wordreverse every word in a string in javaallintitle 3areverse a string in java word by wordhow to reverse words in a string in javajava program to reverse each word in stringreverse string in java word wisereverse string word wise javareverse every other word in a java stringgiven a string 2c reverse each word in the sentence using javareverse string word by word in javahow to print text in reverse word in javareverse string word wise in javareverse string word by word java mainreverse string by words in javajava string reverse word orderreverse words of a string in javareverse a word in javareverse the strign word by word javareverse a string in java word by wordhow to reverse a string in java word by wordhow to reverse string in java each wordreverse a word of string in javareverse the word in string in javareverse a string word wise in javawhat is the reverse word of javareverse a word javawrite a java program to reverse a wordreverse words in a string javareverse each word of string in javareverse a word in a string in javajava reverse wordreverse word order string for javareverse a string in java word by word