StringUtilities.java 540B

123456789101112131415161718192021
  1. public class StringUtilities {
  2. public Character getMiddleCharacter(String word){
  3. return word.charAt((word.length()) / 2);
  4. }
  5. public String removeCharacter(String value, char charToRemove){
  6. String r = "";
  7. for (int i = 0; i < value.length(); i++) {
  8. if (value.charAt(i) != charToRemove) r += value.charAt(i);
  9. }
  10. return r;
  11. }
  12. public String getLastWord(String value) {
  13. String lastWord = value.substring(value.lastIndexOf(" ")+1);
  14. return lastWord;
  15. }
  16. }