I am aware of overflow, performance drops, etc but I need to swap two String values without any temporary variable. I know what cons are and found some effective methods but cannot 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);
Output shows it clear values are swapped. When I look at this seems something related with priority operations but I cannot figure it out in my mind. Please, could someone explain to me what happens?