I have the following method
public String toIndentedString() {
StringJoiner sj = new StringJoiner("\n");
sj.add(rootValue.toString());
for (Tree<T> child : children) {
String childString = child.toIndentedString();
sj.add(childString.replaceAll("(?m)^", " "));
}
return sj.toString();
}
The output it is returning is slightly off, here is an image which shows the output it requires.
Could someone please tell me what I need to change to get this to work?