Experts, I came to know that JavaMe doesn't hava replace method. How can i replace all the string to another string? Method like
replace(String a, String b). ?
Anyone did this before? please share your code?
Experts, I came to know that JavaMe doesn't hava replace method. How can i replace all the string to another string? Method like
replace(String a, String b). ?
Anyone did this before? please share your code?
use temp string & swap both string....
thanks & Regards.
Nilesh
Hi Kumar
Use to trneary operator ,it use easy swap string
By
chandru
Thanks for your reply,
Like this example...
I'm searching for replaceAll() method. I have one string, i want to replace all the string to another string from the original string?String str = "Her name is Tamana and Tamana is a good girl.";
String strreplace = "Sonia";
String result = str.replaceAll("Tamana", strreplace);
System.out.println(result);
Output: Her name is Sonia and Sonia is a good girl.
how can i implement replaceAll() method?
That is called programming. Combine indexOf and substring methods in a loop.
A step could be something likeand repeat if necessary.Code:int pos=str.indexOf("Tamana"); if(pos>-1) str=str.substring(0,pos)+"Sonia"+str.substring(pos+"Tamana".length());
The advanced variant would use StringBuffer for storing the output, and toString it in a single step at the end.