I am aware of overflow, performance degradation, etc., but I need to exchange two String values without any temporary variable. I know what the cons are, and I found some effective methods, but I can not understand one of them.
String a = "abc";
String b = "def";
b = a + (a = b).substring(0, 0);
System.out.printf("A: %s, B: %s", a, b);
The conclusion shows that the net values are reversed. When I look at this, it seems that something is related to priority operations, but I can not understand it in my mind. Please, can someone explain to me what is happening?
source
share