Well, I’m trying to figure out this thing. How would you code something like this (in Javglish):
if(input != a number)
{
do something
}
How would I code this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#Java:
(Poorly optimized, better examples inside the link, like the RegEx one)
Edit for future viewers: The aforementioned RegEx method is much more elegant, but is a little harder to follow, if you aren’t familiar with Regular Expressions: