Results 1 to 6 of 6
  1. #1
    linux0kernel is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Default Replace number to the star

    How can you to replace the 4 numbers to "*", middle of 11 numbers,
    eg
    I hava a String "13309145018", replace result is "133****5018"!

  2. #2
    ojn
    ojn is offline Senior Member
    Join Date
    Aug 2008
    Location
    Stockholm, Sweden
    Posts
    119
    Rep Power
    0

    Default

    If you check out String in the API, you'll find everything you need to solve this problem.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,556
    Rep Power
    25

    Default

    Or you could use the StringBuffer class. It has methods to change the contents of a String(when its in the StringBuffer object).

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default String methods

    Look at the replace & subString methods in the String Class.
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  5. #5
    linux0kernel is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Default

    give me a eg,3Q

  6. #6
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Default

    System.out.println(s.substring(0,3)+"****"+s.subst ring(7,11));

    You will get the answer like 133****5018

Similar Threads

  1. Star pattern help?
    By GeeKunMow in forum New To Java
    Replies: 13
    Last Post: 07-21-2011, 05:59 AM
  2. Find and replace ( in a String
    By hamish10101 in forum New To Java
    Replies: 6
    Last Post: 01-17-2008, 05:51 AM
  3. Using a replace method...
    By paul in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 04:50 AM
  4. problems with replace method
    By cecily in forum New To Java
    Replies: 1
    Last Post: 08-02-2007, 09:11 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
  •