Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using Character.isDigit...

843789Mar 25 2009 — edited Apr 14 2009
I'm using a Character.isDigit for an if statement in a method i'm creating.

What it's supposed to do is if the string supplied is not a valid number it should return 0.0 as the result.

When I compile it, I get an error saying "cannot find symbol - method isDigit(java.lang.String)". Here's my code:
   public double convertDouble (String value) 
   {
       for(int i = 0; i < value.length();i++) {
           if(value = Character.isDigit(value)) {
               value = 0.0;
            }
        }
        return Double.parseDouble(value);
    }
Am i using the Character.isDigit wrong? How do i use it to fulfill what i want to do?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 12 2009
Added on Mar 25 2009
10 comments
896 views