12345678910111213141516171819202122232425262728 |
- package QuizWeek1;
-
- public class StringUtilities {
- public Character getMiddleCharacter(String word){
- int middleChar;
- if ((word.length()/2)%2 == 0){
- middleChar = word.length()/2+1;
-
- }else{
- middleChar = Math.round(word.length()/2);
-
- }
- return word.charAt(middleChar);
-
- }
-
- public String removeCharacter(String value, char charToRemove){
- int removeChar = value.indexOf(charToRemove);
- return value.substring(0,removeChar) + value.substring(removeChar+1);
- }
-
- public String getLastWord(String value) {
- int indexLastWord = value.lastIndexOf(" ");
-
- return value.substring(indexLastWord+1);
- }
- }
|