no soy capaz de entender el siguiente comportamiento de StringBuilder cuando los objetos NULL se anexan a una instancia:comportamiento StringBuffer para NULL objetos
public class StringBufferTest {
/**
* @param args
*/
public static void main(String[] args) {
String nullOb = null;
StringBuilder lsb = new StringBuilder();
lsb.append("Hello World");
System.out.println("Length is: " + lsb.length());// Prints 11. Correct
lsb.setLength(0);
System.out.println("Before assigning null" + lsb.length());
lsb.append(nullOb);
System.out.println("Length now is:" + lsb.length()); // Prints 4. ???
}
}
La última sentencia de impresión no se imprime 0. Puede alguien por favor me ayude a entender ¿el comportamiento?
D *** shoud ha leído la documentación de append (String). Gracias !! –