Sign in to follow this  

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

This topic is 3339 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
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

This topic is 3339 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this