StringUtilities.java 696B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import java.util.Scanner;
  2. public class StringUtilities {
  3. public Character getMiddleCharacter(String word){
  4. //get the middle of the string
  5. return word.charAt(word.length()/2);
  6. }
  7. public String removeCharacter(String value, char charToRemove){
  8. String r = "";
  9. for (int i = 0; i < value.length(); i++) {
  10. if (value.charAt(i) != charToRemove)
  11. r += value.charAt(i);
  12. }
  13. return r;
  14. }
  15. public String getLastWord(String value) {
  16. String lastWord = value.substring(value.lastIndexOf(" ") + 1);
  17. return lastWord;
  18. }
  19. }