Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

In Java, how do you make a Scanner only accept numbers as a valid input? I know there is one way to do it with number.hasNextInt(), but what if I am not using a String?

OpenStudy (espex):

You do not have a choice in the matter. http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html The scanner class was designed to break the stream into string tokens.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!