There is a great article that describes the differences of String concatenation in Java 8 and 9.
Before reading, what do you think the log in Java 9?
public class Alice {
String[] wonders = new String[]{“ cats”, “ eat”, “ bats”};
int wonderIndex = 0; @Override public String toString() {
return wonders[wonderIndex++];
} public static void main(String[] args) {
Alice alice = new Alice();
System.out.println(“Do” + alice + alice + alice + ‘?’);
}
}
You will get the answer and understand why after reading it.