Descripción
public StringBuilder append (char c): este método agrega la representación de char
valor (dado como argumento a este método, durante la llamada) al archivo StringBuilder
ejemplo.
Ejemplo
Aquí mostraremos dos formas de agregar un archivo char
valorar un StringBuilder
ejemplo. Podemos agregar directamente el valor char a StringBuilder usando el método append (char c) o podemos agregarlo usando la variable char como se muestra en el siguiente ejemplo:
import java.lang.StringBuilder; class StringBuilderAppendChar{ public static void main(String[] args) { StringBuilder sb = new StringBuilder("-My String-"); /* Appending char value: This is the simplest way of * appending a character to the StringBuilder instance. * Note the single quote('') here. */ sb.append('a'); /* Appending char variable. In this case the value * of this variable would be converted to the String * before append operation implicitly. */ char ch="b"; sb.append(ch); //No single quote('') in this case // Displaying StringBuilder output System.out.println(sb); } }
Producción:
-My String-ab