I want to remove numbers separated by a comma in a string:
String s= "1000, 2000, 3000, 4000, 1000";
s= s.replace("1000","");
System.out.println(s);
The result is:
", 2000, 3000, 4000,"
I want to cut also leading and tailing commas, so the expected result is:
"2000, 3000, 4000"
How can I do this?
I would use
prints
Or I would use a proper List
prints
If you really have to use String, you can do
prints