1234567891011121314151617181920212223242526 |
- public class StringUtilities {
- public Character getMiddleCharacter(String word){
- char middle;
- if(word.length() % 2 == 1)
- {
- middle = word.charAt((word.length() - 1) / 2);
- }
- else
- {
- middle = word.charAt(word.length() / 2);
- }
- return middle;
- }
-
- public String removeCharacter(String value, char charToRemove){
- String strChar = Character.toString(charToRemove);
- String str = value.replaceAll(strChar, "");
- return str;
- }
-
- public String getLastWord(String value) {
- String[] strArr = value.split(" ");
- return strArr[strArr.length - 1];
- }
- }
|