Skip to content

Commit 9dc9a2b

Browse files
committed
Reverse Words
1 parent 7d61a3b commit 9dc9a2b

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.hellokoding.algorithm;
2+
3+
public class String_ReverseWords {
4+
static String reverseWords(String str) {
5+
String result = "";
6+
String[] words = str.split(" ");
7+
for (int i = words.length - 1; i >= 0; i--) {
8+
result += words[i] + " ";
9+
}
10+
11+
return result;
12+
}
13+
14+
public static void main(String[] args) {
15+
System.out.println(reverseWords("Hello Koding"));
16+
}
17+
}

0 commit comments

Comments
 (0)