L'initialisation de Joiner
est-elle incorrecte ici? J'ai la classe suivante, et quand j'essaye de joindre le tableau exemple paths
avec le joiner
, j'obtiens un NullPointerException
.Guava Joiner lève NPE sur les éléments NULL
public class CPath {
private static final Joiner joiner = Joiner.on("/");
private String[] elements;
@Override
public String toString() {
return joiner.join(elements);
}
}
// main method
final String[] paths = {"a/b/c", "d", "", null, "e/f/g", "h/i", null, ""};
final CPath c3 = new CPath(paths);
c3.toString(); //<<<< NPE