-
In the above mentioned algorithm the author used the library functions to check lowercase letters and to convert it to uppercase. which will be time consuming and makes the algorithm again depend on the external built in functions. it can be speeded up by using ascci values and independent of standard libraries.`
-
public static String toUpperCase(String s) {
if (s == null || "".equals(s)) {
return s;
}
char[] values = s.toCharArray();
for (int i = 0; i < values.length; ++i) {
if ( lHere used the library functions
Character.isLetter(values[i]) &&
Character.isLowerCase(values[i])
//these above 2 checks can be reduced as
values[i]>='a' && values[i]<='z'
) {
// here used library functions
values[i] = Character.toUpperCase(values[i]);
this above line can be changed as
// values[i] = (char) (values[i] - 32);
}
}
return new String(values);
}`