Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to check if a String contains number

user575089Aug 23 2011 — edited Aug 23 2011
How to check if a String contains number ? By number I mean it could be positive decimal or whole number.

Here are my possible inputs and possible outputs to explain specifically.

case 1:
Input: String var="abcd"
output: this is not number

case 2:
Input: String var="123"
output: this is a number. This is a whole number

case 3:
Input: String var="123.45"
output: this is number . This is a decimal number

whats the right approach to check this ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2011
Added on Aug 23 2011
15 comments
1,673 views