1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import java.util.Scanner;
-
- public class StringUtilities {
- public Character getMiddleCharacter(String word){
- //get the middle of the string
-
-
-
- return word.charAt(word.length()/2);
-
-
-
-
- }
-
-
-
- public String removeCharacter(String value, char charToRemove){
-
- String r = "";
-
- for (int i = 0; i < value.length(); i++) {
-
- if (value.charAt(i) != charToRemove)
- r += value.charAt(i);
- }
- return r;
-
-
-
- }
-
-
- public String getLastWord(String value) {
- String lastWord = value.substring(value.lastIndexOf(" ") + 1);
- return lastWord;
- }
-
- }
-
|