StringUtilities.java 718B

1234567891011121314151617181920212223242526272829303132
  1. public class StringUtilities {
  2. public Character getMiddleCharacter(String word){
  3. int position;
  4. String middleChar;
  5. position = (word.length()/2);
  6. return (word.substring(position,position+1)).charAt(0);
  7. }
  8. public String removeCharacter(String value, char charToRemove){
  9. char[] chars=value.toCharArray();
  10. String str="";
  11. for(int i=0;i<chars.length;i++){
  12. if (chars[i]==charToRemove) {
  13. continue;}
  14. else{
  15. str+=chars[i];
  16. }
  17. }
  18. return (str);
  19. }
  20. public String getLastWord(String value) {
  21. String strArr[] = value.split(" ");
  22. return strArr[strArr.length-1];
  23. }
  24. }