12345678910111213141516171819202122232425262728293031 |
- public class StringUtilities {
- public Character getMiddleCharacter(String word){
- char wordResult = 'a';
-
- if (word.length()%2 == 1) {
- int oddLength = word.length()/2;
- int evenLength = word.length()/2-1;
- // wordResult = word.substring(oddLength, oddLength + 1);
- }
- else {
- // wordResult = word.substring(evenLength, evenlength + 1);
- }
- return wordResult;
- }
-
-
- public String removeCharacter(String value, char charToRemove){
- String newString = "";
-
- for (int i = 0; i < value.length(); i ++) {
- if (value.charAt(i) != charToRemove) newString += value.charAt(i);
- }
-
- return newString;
- }
-
- public String getLastWord(String value) {
- return value.substring(value.lastIndexOf(" ")+1);
- }
- }
|