saviok
saviok

Reputation: 497

isDigit(char) not working

I'm not able to use isDigit() in my program. When I use it says "The method isDigit(char) is undefined for type calculator". *calculator is my class. *I'm trying to go through all the characters of a string and check whether they are valid input characters for a calculator.

Upvotes: 2

Views: 3972

Answers (1)

dogbane
dogbane

Reputation: 274572

isDigit is a static method of the Character class. To call a static method you should prefix the method reference with the name of the class it belongs to, like this:

Character.isDigit(ch);

Upvotes: 6

Related Questions