This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors