Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: How to remove comma before an String?

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to remove comma before an String?

    How to remove comma before an String?
    myString = bhanu,balaji,guddanti
    i wnt my output will be
    outString = bhanu,balaji guddanti(removing last comma before an string)

    i'm using jdk1.4..

    i'm new to java..please suggest me an solution
    Appreciate a lot in advance...

    Thanks
    Bhanu


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: How to remove comma before an String?

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/46965-how-remove-comma-before-string.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: How to remove comma before an String?

    There are several different ways you can do this.

    I've read your cross post and people have suggested reading the String API. Have you done this?

    You could use the Split method and use a comma as a delimiter. Then reconstruct the String...
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  4. #4
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    471
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: How to remove comma before an String?

    Quote Originally Posted by JavaPF View Post
    ... You could use the Split method and use a comma as a delimiter. Then reconstruct the String...
    The OP probably wants to find the last index of the comma...

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,469
    My Mood
    Grumpy
    Thanks
    0
    Thanked 159 Times in 150 Posts

    Default Re: How to remove comma before an String?

    Quote Originally Posted by dlorde View Post
    The OP probably wants someone else to do the work
    There, fixed!
    Improving the world one idiot at a time!

Similar Threads

  1. How to remove the regular expression from a string ?
    By srimanta in forum Java Theory & Questions
    Replies: 5
    Last Post: July 20th, 2011, 03:07 PM
  2. How to remove the last comma
    By fride360 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 29th, 2011, 07:20 AM
  3. not able to remove from ArrayList
    By harsha_c in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 3rd, 2011, 02:28 AM
  4. How to remove the in-between spaces in a String? Please help.
    By marksquall in forum Java Theory & Questions
    Replies: 2
    Last Post: February 4th, 2010, 03:19 PM
  5. How to remove letters
    By noobish in forum Java Theory & Questions
    Replies: 13
    Last Post: October 3rd, 2009, 10:36 PM