/** * An introduction to Strings and String methods. * * @author Wilhem Alcivar */ public class StringParser { private static String s1; /** * Takes a String and returns that String with all characters uppercased. * E.G. cat would become CAT. dOnUt would become DONUT. * * @param s * @return String */ public static String upperCaseString(String s) { return s.toUpperCase(); } /** * Takes a String and returns that String with all characters lowercased. * E.G. MOUSE would become mouse. dOnUt would become donut. * * @param s * @return String */ public static String lowerCaseString(String s) { return s.toLowerCase(); } /** * Takes a String and returns the first character of that string. * E.G. cat would return c. Embark would return E. * * @param s * @return String */ public static Character getFirstCharacter(String s) { return s.charAt(0); } /** * Takes a String and returns the character at index n of that string. * E.G. cat, 2 would return t. Embark, 4 would return r. * * @param s * @param n * @return String */ public static Character getNthCharacter(String s, Integer n) { return s.charAt(n); } /** * Takes a String and returns that string with the first character uppercased. * E.G. cat would return Cat. cofFee would return CofFee. * * @param s * @return String */ public static String upperCaseFirstCharacter(String s) { s1 = s.substring(0,1).toUpperCase() + s.substring(1); return s1; } /** * Takes a String and returns that string with the first character of each word in it uppercased * and then joined. * E.G. dog whistle would return DogWhistle. adjuNCT pRoFessOR would return AdjuctProfessor. * * @param s * @return String */ public static String camelCaseString(String s) { //String s2 = ""; s1 = s.toLowerCase(); //s1 = s1.subString(0,1) + s1.subString(1); //StringBuffer bf = new StringBuffer(s1); for(int i=0;i