George Avilez wrote:so parse would do the trick?
Specifically,
Integer.parseInt().
You should remember to be specific and
accurate when you're writing (or talking about)
Java, because the compiler is NOT forgiving about things that may seem trivial to you - like spelling and capitalization.
long is NOT the same thing as
Long.
Another alternative would be to check that each character in the string is a digit (have a look at the
Character.isDigit() method); but in this rare case it might be better to use
parseInt() and only accept the value if it doesn't throw an exception.
I say 'rare' because using Exceptions for flow control is usually NOT a good idea; but in this case, it really does achieve exactly what you want.
BTW: Aren't SSNs 9 digits? Mine was.
Winston