What is the equivalent for this C# code in Java?
String newSTr = string.Join(" ", xString.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries));
Basically the function trims all extra spaces (trailing and spaces inside within the string). Thanks
Let’s say i have this examples:
I have this string. == I have this string.
I have this string . == I have this string .
result: “I have this string.”
Works with leading/trailing whitespace too.