I'm trying to make a method to remove spaces in a given String. this is my code right now:
public class sorter {
public static String nameConvertion(String name) {
name = name.replaceAll("\\s","");
return name;
}
public static void main(String args[])
{
String name = " 123 123 123 123 ";
nameConvertion(name);
System.out.println(name);
}
}
But it doesn't remove the spaces, what am i missing?