Results 1 to 3 of 3
  1. #1
    newToJava3 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default Removing last character from a String

    I have a string which has alot of commas. What I want to do is remove the last comma in the String for example:

    1,2,3,4,5,

    I want it to be 1,2,3,4,5

    I dont want to remove all the commas just the last character.

    Thank you for your help

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    String (Java Platform SE 6)

    string = string.substring(0, string.length()-1);

  3. #3
    newToJava3 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

Similar Threads

  1. split the String into character...
    By Godfrey125 in forum New To Java
    Replies: 2
    Last Post: 11-23-2010, 06:21 PM
  2. compare String to the character .
    By Bulelakes in forum JDBC
    Replies: 12
    Last Post: 07-28-2010, 12:35 PM
  3. Taking a character off the end of a string.
    By AJArmstron@aol.com in forum New To Java
    Replies: 5
    Last Post: 05-05-2010, 03:56 AM
  4. how to get next character/string
    By doha786 in forum New To Java
    Replies: 3
    Last Post: 03-28-2009, 05:04 AM
  5. Replies: 1
    Last Post: 01-11-2008, 11:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •