StringUtilities.java 771B

1234567891011121314151617181920212223242526272829303132
  1. public class StringUtilities {
  2. public Character getMiddleCharacter(String word){
  3. int middle = word.length();
  4. int x;
  5. char m = 0;
  6. if(middle % 2 == 0){
  7. x = middle / 2 - 1;
  8. m = word.charAt(x);
  9. }else if (middle % 2 != 0){
  10. x = middle / 2;
  11. m = word.charAt(x);
  12. }
  13. return m;
  14. }
  15. public String removeCharacter(String value, char charToRemove){
  16. // String newestword = value.replaceAll(charToRemove,"");
  17. //return newestword;
  18. return null;
  19. }
  20. public String getLastWord(String value) {
  21. String [] container = value.split(" ");
  22. String x = container[container.length -1];
  23. return x;
  24. }
  25. }