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!

Testing for blank input

707697Mar 18 2009 — edited Mar 18 2009
I'm writing a program and would like to supply the user with the option to use their own values or use the default values of the program. I'd like to have it set up so the user can just hit enter in response to a question and use default values. I'm having trouble figuring out how to test for null/no/blank? input though. This is what I've got so far.
System.out.println("Please enter 4 superincreasing numbers separated by a comma and a space");
		System.out.println("Example: 1, 2, 4, 8");
		input = stdIn.nextLine();

		System.out.println("Input is:\""+ input +"\"");
		if (input == "" || input == null) //need help with this line
			System.out.println("No input");
		else
			System.out.println("Some input");
Unfortunately for me, I'm getting some input every time. What value do I need to test input against to see if nothing was entered?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 15 2009
Added on Mar 18 2009
20 comments
234 views