Skip to main content
cambié el código para que lo que no sea la primera letra lo cambie a minúscula.
Origen Enlace
AlbertoLopez
  • 1.6k
  • 2
  • 10
  • 15
public static String convierte(String string) {
    if (string == null) {
        return null;
    }
    StringBuilder builder = new StringBuilder();
    StringTokenizer st = new StringTokenizer(string," ");
    while (st.hasMoreElements()) {
        String ne = (String)st.nextElement();
        if (ne.length()>0) {
            builder.append(ne.substring(0, 1).toUpperCase());
            builder.append(ne.substring(1).toLowerCase()); //agregado
            builder.append(' ');
        }
    }
    return builder.toString();
}
public static String convierte(String string) {
    if (string == null) {
        return null;
    }
    StringBuilder builder = new StringBuilder();
    StringTokenizer st = new StringTokenizer(string," ");
    while (st.hasMoreElements()) {
        String ne = (String)st.nextElement();
        if (ne.length()>0) {
            builder.append(ne.substring(0, 1).toUpperCase());
            builder.append(ne.substring(1));
            builder.append(' ');
        }
    }
    return builder.toString();
}
public static String convierte(String string) {
    if (string == null) {
        return null;
    }
    StringBuilder builder = new StringBuilder();
    StringTokenizer st = new StringTokenizer(string," ");
    while (st.hasMoreElements()) {
        String ne = (String)st.nextElement();
        if (ne.length()>0) {
            builder.append(ne.substring(0, 1).toUpperCase());
            builder.append(ne.substring(1).toLowerCase()); //agregado
            builder.append(' ');
        }
    }
    return builder.toString();
}
Origen Enlace
AlbertoLopez
  • 1.6k
  • 2
  • 10
  • 15

public static String convierte(String string) {
    if (string == null) {
        return null;
    }
    StringBuilder builder = new StringBuilder();
    StringTokenizer st = new StringTokenizer(string," ");
    while (st.hasMoreElements()) {
        String ne = (String)st.nextElement();
        if (ne.length()>0) {
            builder.append(ne.substring(0, 1).toUpperCase());
            builder.append(ne.substring(1));
            builder.append(' ');
        }
    }
    return builder.toString();
}