Results 1 to 9 of 9
  1. #1
    tjt
    tjt is offline Member
    Join Date
    Jul 2012
    Posts
    27
    Rep Power
    0

    Default Strings. Deleting certain character in a String

    Hello, How could I delete certain characters in a String, totally deleting it not just replacing it with a space..
    Because I need to get the length of the letters only.. The space is always added in the counting of the length :D

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: Strings. Deleting certain character in a String

    Can't you just do someting like:

    Java Code:
    str = str.replace("X", "");
    For more detail you can read it here: String (Java 2 Platform SE 5.0)

  3. #3
    tjt
    tjt is offline Member
    Join Date
    Jul 2012
    Posts
    27
    Rep Power
    0

    Default Re: Strings. Deleting certain character in a String

    hmm.. the next cannot be an empty string...
    Strings. Deleting certain character in a String-hello.png

  4. #4
    tjt
    tjt is offline Member
    Join Date
    Jul 2012
    Posts
    27
    Rep Power
    0

    Default Re: Strings. Deleting certain character in a String

    ha, it doesnt work if I use a variable... but I need the variable to determine the letter I want to be replaced.

  5. #5
    tjt
    tjt is offline Member
    Join Date
    Jul 2012
    Posts
    27
    Rep Power
    0

    Default Re: Strings. Deleting certain character in a String

    Ok I got it now.. thanks :D

  6. #6
    tjt
    tjt is offline Member
    Join Date
    Jul 2012
    Posts
    27
    Rep Power
    0

    Default Re: Strings. Deleting certain character in a String

    hmm how about changing only one character.. .replace changes all the occurrence of that character in a string.. example "develop" change the first e into something else ... like duvelop

  7. #7
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: Strings. Deleting certain character in a String

    Quote Originally Posted by tjt View Post
    hmm how about changing only one character.. .replace changes all the occurrence of that character in a string.. example "develop" change the first e into something else ... like duvelop
    I promise that you will find the necessary method in here: String (Java Platform SE 7 )
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  8. #8
    tjt
    tjt is offline Member
    Join Date
    Jul 2012
    Posts
    27
    Rep Power
    0

    Default Re: Strings. Deleting certain character in a String

    can you give me a hint ;)

  9. #9
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: Strings. Deleting certain character in a String

    The method name has replace in it.

    And it's not the [hint]first[/hint] method on the list.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

Similar Threads

  1. String problem: deleting
    By BlueBird in forum New To Java
    Replies: 3
    Last Post: 03-18-2011, 06:21 AM
  2. Handling Multi byte Character Strings
    By madhav1351 in forum Advanced Java
    Replies: 2
    Last Post: 09-22-2010, 01:55 PM
  3. Hejp with deleting string from JTextField
    By satin in forum New To Java
    Replies: 9
    Last Post: 11-09-2008, 12:05 AM
  4. [SOLVED] Handling strings including " character
    By flywheel in forum New To Java
    Replies: 5
    Last Post: 09-29-2008, 04:45 AM
  5. deleting characters from a String
    By Hayzam in forum New To Java
    Replies: 4
    Last Post: 08-29-2008, 01:14 PM

Tags for this Thread

Posting Permissions

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