Posted by Lisa on Wednesday, September 30, 2009 at 2:57am.
You would read the password and store it as as String. Then there are many ways to check if it is a single word.
You need to know what the separators of words are. Most of the time we think of spaces, but there are tabs, punctuation marks, parentheses, etc.
If it is a single character (space) you can use the string function indexOf(String, character) to see if it returns a non negative number.
If it is a collection of different characters, you may think of using the string function matches(regexp) which allows you to specify many characters at the same time.
If you read up the String class of the Java API, you will find a lot of possibilities.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
There is even a video on Strings on UTube (I have not perused it):
http://www.youtube.com/watch?v=tU67suVZVfQ
Related Questions
java - Write a java application that finds the smallest of several integers. ...
programming - write a program that maintains two parallel arrays. after th ...
computer science - hi i am using java to make a quiz... i am using JFrame and ...
computer science - in visual logic You will need to design an application that ...
computer - Which of the following operating system types is used in PDAs? (...
Computer Science(python) - Service Price Basic Lawn Mowing $20 Trimming and ...
Computer Science-Java - Hi, I have to write a method that returns my first name...
Computer Science (MATLAB) - I had a test in my computer science course in which ...
Computer Science (MATLAB) - I had a test in my computer science course in which ...
Computer science - A. Given a = 5, b = 1, x = 10, and y = 5, create a program ...
For Further Reading