Last active
October 8, 2016 20:31
-
-
Save leonardreidy/66bb40184e8ee8bea35b to your computer and use it in GitHub Desktop.
Simple Java class containing methods for performing common actions on Strings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringUtilities | |
{ | |
/** | |
* Check if input string is a vowel | |
* Author: http://stackoverflow.com/users/1357341/arshajii | |
**/ | |
public static boolean isVowel(String inStr) | |
{ | |
return "aeiou".indexOf(inStr.toLowerCase()) >= 0; | |
} | |
/** | |
* Check if input string is a consonant | |
* Author: http://stackoverflow.com/users/1357341/arshajii | |
**/ | |
public static boolean isConsonant(String inStr) | |
{ | |
return "bcdfghjklmnpqrstvwxyz".indexOf(inStr.toLowerCase()) >= 0; | |
} | |
/** Given a String array containing words, | |
* join the elements of the array with the | |
* given separator and return to caller | |
* Author: http://stackoverflow.com/users/4108825/ivanp | |
**/ | |
public static String join(String[] strArr, String separator) | |
{ | |
String returnVal = ""; | |
for(String s: strArr){ returnVal += separator + s; } | |
return returnVal.replaceFirst(separator, ""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment