String issues

uhm.. lets say if got a string with a value of "LONDON" and want to delete the "ND" to make it LOON.. how should i go about doing that..

String a ="LONDON"

if(a.contains("ND"){

//what goes here?

}

[395 byte] By [Arch_Bytesa] at [2007-11-26 19:23:21]
# 1
String are immutable, you have to create a new String with that or use StringBuilder-Bz
Bz_Unknowna at 2007-7-9 21:44:51 > top of Java-index,Java Essentials,New To Java...
# 2
String builder?
Arch_Bytesa at 2007-7-9 21:44:51 > top of Java-index,Java Essentials,New To Java...
# 3

String has a method to do what you want but as mentioned Strings are immutable so it returns a new String.

String b = a.method();

You will have to look up the method and figure out how it works. If you can't come back here and post your code and explain what you have tried and what isn't working.

floundera at 2007-7-9 21:44:51 > top of Java-index,Java Essentials,New To Java...
# 4
Yes, [url= http://java.sun.com/javase/6/docs/api/java/lang/StringBuilder.html]StringBuilder[/url]
DrLaszloJamfa at 2007-7-9 21:44:52 > top of Java-index,Java Essentials,New To Java...
# 5
String newString = a.replaceAll("ND","");Will replace all occurences of ND.
CjavaVMa at 2007-7-9 21:44:52 > top of Java-index,Java Essentials,New To Java...
# 6
thanks again guys..^_^
Arch_Bytesa at 2007-7-9 21:44:52 > top of Java-index,Java Essentials,New To Java...