Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
validation- is it a number
David Shepherd
Ranch Hand
Posts: 35
posted 23 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am looking for the easy way to validate a
string
and take action if the input string is a number (or can be parsed into a number). Is there an easy way to check a string to see if it can be turned into an integer?
Thanks.
Angela Lamb
Ranch Hand
Posts: 156
posted 23 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
There are functions in the Integer class for this:
String inputStr = inputBox.getText(); int inputInt; try { inputInt = Integer.parseInt(inputStr); } catch (NumberFormatException e) {} // if the input is not a number
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Reg. Math : ceil and floor
failed HFS book mock exam
Length of Strings
Easy way to verify an IP #?
charAt with longs?
More...