1234567891011121314151617181920212223242526272829 |
- public class StringUtilities {
- public Character getMiddleCharacter(String word){
- char result;
- int length = word.length();
-
- if(length%2 == 1){ //odd
- result = word.charAt((length-1)/2);
- } else { //even
- result = word.charAt((length/2));
- }
-
- return result;
- }
-
- public String removeCharacter(String value, char charToRemove){
- String strToRemove = Character.toString(charToRemove);
- String result = value.replace(strToRemove,"");
-
- return result;
- }
-
- public String getLastWord(String value) {
- String[] strArray = value.split(" ");
- String result = strArray[strArray.length-1];
-
- return result;
- }
- }
|