123456789101112131415161718192021222324252627282930 |
- public class StringUtilities {
- public Character getMiddleCharacter(String word){
- int value=0;
- char middle=0;
-
- if(word.length()%2==0){
- value=(word.length() / 2-1);
- middle= word.charAt(value);
- } else if (word.length()%2 !=0){
- value=(word.length() / 2);
- middle= word.charAt(value);
- }
- return middle;
- }
-
- public String removeCharacter(String value, char charToRemove){
- int word = value.length();
- String start = value.substring(0, word / 2);
- String end = value.substring((word / 2) + 1 , value.length());
-
- String sum= start + end;
- return sum;
- }
-
- public String getLastWord(String value) {
- String lastWord = value.substring(value.lastIndexOf(" ")+1);
- return lastWord;
- }
- }
|