12345678910111213141516171819202122232425262728293031 |
- public class StringUtilities {
- public Character getMiddleCharacter(String word){
- int post;
- int leng;
- if (word.length()% 2 == 1){
- post=word.length()/2;
- leng= 1;
- } else {
- post=word.length()/2-1;
- leng = 1;
- }
- String mid = word.substring(post, post
- + leng);
- char output = mid.charAt(0);
- return output;
-
- }
-
- public String removeCharacter(String value, char charToRemove){
-
- String newString = value.replaceAll(Character.toString(charToRemove), "");
-
- return newString;
- }
-
- public String getLastWord(String value) {
- String lastWord = value.substring(value.lastIndexOf(" ")+1);
- return lastWord;
- }
- }
|