Post a New Question

Java

posted by .

Is there a method in Java in which to see if an integer value contains characters?

  • Java -

    By definition, an integer value does not contain characters (apart from the minus sign), otherwise the value is invalid.

    If you have a String and would like to check for foreign characters, you can try:
    the matches() method using a regular expression.
    For example, if you suspect alphabetic characters, you can check using:
    if(someString.matches("[a-zA-Z]")
    {
    // do something
    }

    If you want to scan for all non-numeric characters, you can replace with
    ...matches("[^0-9]")...

Answer This Question

First Name:
School Subject:
Answer:

Related Questions

More Related Questions

Post a New Question