Browse Source

updated String Utilities

Bo Lee 6 years ago
parent
commit
42a936f5bc

+ 2
- 2
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java View File

75
      * @return the first sequence of characters
75
      * @return the first sequence of characters
76
      */
76
      */
77
     public static String getFirstWord(String spaceDelimitedString){
77
     public static String getFirstWord(String spaceDelimitedString){
78
-        String [] newStringArray = spaceDelimitedString.split(" ");
78
+        String [] newStringArray = spaceDelimitedString.split(" ", 0);
79
         return newStringArray[0];
79
         return newStringArray[0];
80
     }
80
     }
81
 
81
 
84
      * @return the second word of a string delimited by spaces.
84
      * @return the second word of a string delimited by spaces.
85
      */
85
      */
86
     public static String getSecondWord(String spaceDelimitedString){
86
     public static String getSecondWord(String spaceDelimitedString){
87
-        String [] newStrArr = spaceDelimitedString.split(" ");
87
+        String [] newStrArr = spaceDelimitedString.split(" ", 0);
88
         return newStrArr[1];
88
         return newStrArr[1];
89
     }
89
     }
90
 
90
 

+ 1
- 1
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.java View File

154
         String expected = "Wilmington";
154
         String expected = "Wilmington";
155
 
155
 
156
         // : When
156
         // : When
157
-        String actual = StringUtilities.getFirstWord(input);
157
+        String actual = StringUtilities.getSecondWord(input);
158
 
158
 
159
         // : Then
159
         // : Then
160
         assertEquals(expected, actual);
160
         assertEquals(expected, actual);

BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class View File


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.class View File