get the integer value using isNumber()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sang
    New Member
    • Sep 2006
    • 83

    get the integer value using isNumber()

    I am trying to get the number that are present in the input string by using the isNumber(), but i have no idea about that any one help me.

    input for the program is "java123"
    output is only "123"

    how it is possible,pls give me the code

    Thanks
    Sang
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by sang
    I am trying to get the number that are present in the input string by using the isNumber(), but i have no idea about that any one help me.

    input for the program is "java123"
    output is only "123"

    how it is possible,pls give me the code

    Thanks
    Sang
    Convert the String toCharArray() then use the Character.isDig it() to loop through the array.
    Better still, use regular expressions

    Comment

    • sang
      New Member
      • Sep 2006
      • 83

      #3
      please give me the source code

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by sang
        please give me the source code
        Maybe you should try it first. It might be easier than you think.
        I find learning more fun by trying out things myself first.

        Comment

        • D_C
          Contributor
          • Jun 2006
          • 293

          #5
          I pseudocoded an anwer to that in your other thread. It's better to keep one problem to one thread. Then you don't have to re-explain the situation every time you discover the problem is a little different than you thought.

          Comment

          Working...