Jump to content
  • Advertisement
Sign in to follow this  
Nanook

read double, but if blank input do something else[java]

This topic is 3555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to ask the user for a double value and read it in using nextDouble() method in the Scanner class from the keyboard.. but if the user just hits enter I want to register that aswell.. how can I do this as easy as possible?

Share this post


Link to post
Share on other sites
Advertisement
Yeah, well.. I dont think that would work from the keyboard though? I came up with a way to do it though.. I read in a nextLine instead.. (String) then checked if that was empty and then if it wasn't I tried to parse it to a double..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!