chrstian ferma wrote:Just want to have an idea how to do this editing the last 3 letters of a string that i retrieve from database
Most of the answers so far have concentrated on dealing with this code
as a String. My question is: Is it really
just a String?
The formatting would suggest that it's actually a representation of something very specific (like, for example, a phone number, or a SKU, or a barcode) and, in that case, I'd suggest creating a Java class that encapsulates it, because THEN you can add logic to update any part of it you like.
Just because the database happens to store it as a String doesn't mean that
you have to. Java is an
Object-Oriented language, so things usually work best if you use strongly-typed objects to store your information; and I'd say that "111-222-333-000" is simply a String representation of something that isn't actually a string at all.
My 2¢
Winston
PS: You may be interested in reading the
StringsAreBad page, which expands on this exact point.