This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
in my program, i want the user to enter an integer. if they enter a double or character, i don't want the program to crash. i want it to go into a while loop that keeps running until they enter an integer. i have no idea how to get the program to keep running when the input is invalid... can someone help?
Originally posted by ashley sands: ...i want it to go into a while loop that keeps running until they enter an integer. i have no idea how to get the program to keep running when the input is invalid...
Welcome to JavaRanch!
It sounds like you do have an idea: "go into a while loop that keeps running until they enter an integer." That suggests something like this...
So the questions are how do you get the input and how do you test the input to see if it's an int? What have you tried so far? [ February 22, 2007: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
ashley sands
Greenhorn
Joined: Feb 22, 2007
Posts: 2
posted
0
i know how to get input and form the while loop and all of that, i just don't know how to test if it's an integer...
Herman Schelti
Ranch Hand
Joined: Jul 17, 2006
Posts: 387
posted
0
hi Ashley,
Just look at the Javadocs of the Integer class.
Herman
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.