This discussion is archived
5 Replies Latest reply: Apr 28, 2008 6:18 AM by 807601 RSS

String insertion problem

807601 Newbie
Currently Being Moderated
Hi all,

i hava a aplhanumeric string and i have to insert this string in the ascending order of the numseric digits.like if i have stored the String as

str="Cus001"

then what i am doing is

String tmp=str.substring(4);

int incmt=Integer.parseint(tmp1);

incmt=incmt++;

String tmp1=str.substring(0,5);

now the string to be inserted is str=tmp1.concat(incmt);

but it is creating problem when i am inserting the string as "Cus010"
  • 1. Re: String insertion problem
    807601 Newbie
    Currently Being Moderated
    not really sure of ur prob..... could u pls specify why r u using increment operator n then doing substring???? r all ur strings of same length??? what prob r u facing????? it is logic level or some exception?

    P.S. would be helpful if u could give ur entire code

    Edited by: no_screen_name on Apr 26, 2008 6:28 AM
  • 2. Re: String insertion problem
    807601 Newbie
    Currently Being Moderated
    please don't cross-post (with a different screen name, no less).

    [http://forum.java.sun.com/thread.jspa?threadID=5290249&tstart=0]
  • 3. Re: String insertion problem
    807601 Newbie
    Currently Being Moderated
    If all of the strings start with "Cus" and there are always three digits, you should get correct results using String's built-in comparator.
    Ashish_Pandey1321 wrote:
    incmt=incmt++;
    Great Googamooga! Please tell me that line was meant as a joke! :D

    @no_screen_name, would you please try to use standard English in your posts? Most forum members (including myself) find sms-speak very annoying. Also, please don't use so many periods (fullstops) and question marks. One per sentence is all you need; the rest just clutter up your message and make it more difficult to read. The same goes for other puctuation characters.
  • 4. Re: String insertion problem
    807601 Newbie
    Currently Being Moderated
    @uncle_alice: Sorry for that. I shall take care next time.
  • 5. Re: String insertion problem
    807601 Newbie
    Currently Being Moderated
    no_screen_name wrote:
    @uncle_alice: Sorry for that. I shall take care next time.
    Thank you.