“String java Substitua os últimos 4 caracteres” Respostas de código

Substitua o último char em string java

if (fieldName.endsWith(",")) {
    fieldName = fieldName.substring(0, fieldName.length() - 1) + " ";
}
Distinct Dog

String java Substitua os últimos 4 caracteres

public static String replaceLastFour(String s) {
    int length = s.length();
    //Check whether or not the string contains at least four characters; if not, this method is useless
    if (length < 4) return "Error: The provided string is not greater than four characters long.";
    return s.substring(0, length - 4) + "****";
}
Angry Albatross

Respostas semelhantes a “String java Substitua os últimos 4 caracteres”

Perguntas semelhantes a “String java Substitua os últimos 4 caracteres”

Mais respostas relacionadas para “String java Substitua os últimos 4 caracteres” em Java

Procure respostas de código populares por idioma

Procurar outros idiomas de código