Hello

I have the following:

String somestring="203/9834/345";
somestring.replace("/","");
System.out.println(somestring);

But it does not remove the slashes. How can I remove them?

Thanks

Use replaceAll() instead (String API doc).

Strings in Java are immutable - ie their content never changes. The replace method therefore does not change the original String. It returns a new String that has the replacements made...

      String somestring="203/9834/345";
      String replaced = somestring.replace("/","");
      System.out.println(replaced);

That was it JamesCherrill

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.