StringUtilities.java 675B

1234567891011121314151617181920212223242526
  1. public class StringUtilities {
  2. public Character getMiddleCharacter(String word){
  3. char middle;
  4. if(word.length() % 2 == 1)
  5. {
  6. middle = word.charAt((word.length() - 1) / 2);
  7. }
  8. else
  9. {
  10. middle = word.charAt(word.length() / 2);
  11. }
  12. return middle;
  13. }
  14. public String removeCharacter(String value, char charToRemove){
  15. String strChar = Character.toString(charToRemove);
  16. String str = value.replaceAll(strChar, "");
  17. return str;
  18. }
  19. public String getLastWord(String value) {
  20. String[] strArr = value.split(" ");
  21. return strArr[strArr.length - 1];
  22. }
  23. }