|
@@ -1,7 +1,5 @@
|
1
|
1
|
package com.zipcodewilmington.danny_do_better_exercises;
|
2
|
2
|
|
3
|
|
-import static java.lang.System.*;
|
4
|
|
-
|
5
|
3
|
/**
|
6
|
4
|
* Created by dan on 6/14/17.
|
7
|
5
|
*/
|
|
@@ -78,8 +76,8 @@ public class StringUtilities {
|
78
|
76
|
* @return the first sequence of characters
|
79
|
77
|
*/
|
80
|
78
|
public static String getFirstWord(String spaceDelimitedString){
|
81
|
|
-
|
82
|
|
- return null;
|
|
79
|
+ int spacer = spaceDelimitedString.indexOf(" ");
|
|
80
|
+ return spaceDelimitedString.substring(0, spacer);
|
83
|
81
|
}
|
84
|
82
|
|
85
|
83
|
/**
|
|
@@ -87,7 +85,8 @@ public class StringUtilities {
|
87
|
85
|
* @return the second word of a string delimited by spaces.
|
88
|
86
|
*/
|
89
|
87
|
public static String getSecondWord(String spaceDelimitedString){
|
90
|
|
- return null;
|
|
88
|
+ int spacer = spaceDelimitedString.lastIndexOf(" ");
|
|
89
|
+ return spaceDelimitedString.substring(spacer);
|
91
|
90
|
}
|
92
|
91
|
|
93
|
92
|
/**
|
|
@@ -95,6 +94,6 @@ public class StringUtilities {
|
95
|
94
|
* @return an identical string with characters in reverse order.
|
96
|
95
|
*/
|
97
|
96
|
public static String reverseTheTwo(String stringToReverse){
|
98
|
|
- return null;
|
|
97
|
+ return stringToReverse;
|
99
|
98
|
}
|
100
|
99
|
}
|