Hie guys Iam looking for a java console application that accepts a string of 80 characters from a user and determine the number of words in the string taking care that there may be more than one spaces between words. The program should check that there is more than one word in the string and determine that how many characters the string will need to be of length 80.

Recommended Answers

All 2 Replies

String.split()

javaAddict is right.
Use the String.split() function which returns (an array of Strings) String[].
You can get the length of the String[] to determine how many words there are.

Do you have any code for this already?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.