The code is as following:
package zad;
import java.util.*;
public class zadaca_palindrom {
public static void main(String[] args) {
Scanner unos = new Scanner(System.in);
System.out.println("Unesi recenicu:");
String str = unos.next();
String str1 = str.replaceAll("\\s+", "");
System.out.println(str1);
}}
When I enter a String, for example "My name is John Doe" I want my program to remove the white spaces. But when I run it it just outputs the first word of my string(in this case "My"). Any help is welcome! Thanks