can anyone help me to find a solution to this problem in Java 8:
A string of characters is composed of multiple spaces is given to you. You must remove all unnecessary spaces by writing an algorithm.
Entry: String containing a sentence. Output: String containing the same sentence without unnecessary spaces.
Example: For the following entry: "I (3spaces) live (3spaces) on (3spaces) earth." The output is: "I live on earth."