Possible Duplicate:
How to check that Java String is not all whitespaces
Scanner kb = new Scanner(System.in);
String random;
System.out.print("Enter your word: ");
random = kb.nextLine();
if (random.isEmpty()) {
System.out.println("No input detected!");
} else {
System.out.println(random);
}
The above code doesn't account for when the user makes a space. It'll still print the blank line, when the user does a space and presses enter.
How do I fix this?