Skip to Main Content

New to Java

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!

limit input to 4 numbers ranging from 0001-9999

808490Oct 26 2010 — edited Oct 29 2010
Hello helpful Java friends,

I am trying to limit the user to enter in an ID number that is 4 ints long and has leading zeros. So if the user enter 2 the code will make it 0002. The user also has to enter only ints. I am thinking it is a try catch but am not sure how to do it so far. Any help would be great. Thank you!!

-Brian
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2010
Added on Oct 26 2010
21 comments
2,557 views