i am having a doubt on how can i append to the start of string,i tried few methods myself
of StringBuffer like append() but still it gets appended to the end position i tried Pattern and Matcher classes (m.start() for start position of string) as well,but could'nt get the clue onto how to go ahead with appending string to start position.
but i want to append it to the start position For ex like String replaced="Placement Date" i am trying to append "]" to the string but after i append it shows me result as "Placement Date]" i wanted that string should be "[Placement date]"
so any help and any suggestion onto which method i must use will be realy great
Thanks in advance Dhwani:>Winning is not important but it is the only thing.
Strings are immutable - once you create one, you can't change it. Now, that's not to say you can't create a new one like you want.
The simplest way would be to just 'add' them together:
If this is all you're doing, and you're not doing it a lot, it will work fine. You just need to be aware that there is some heavy overhead here, and doing it this way thousands or millions of times will cause SERIOUS performance/memory issues.
Never ascribe to malice that which can be adequately explained by stupidity.
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
9
posted
0
And if you do need to use StringBuffer (or even better StringBuilder) to improve performance, take a look at the insert method.
Joanne
dhwani mathur
Ranch Hand
Joined: May 08, 2007
Posts: 621
posted
0
Hi All
Thanks a lot to fred rosenberger ,your post cleared my lots of concepts on String,
Thanks a lot to Joanne Neal i used StringBuffer so as to improve performance.
Things are working now,
Dhwani:>Winning is not important but it is the only thing.