I want to take user input for whatever words they may enter through a buffered reader and put them into an array. Then I want to print out each word on a separate line. So I know I need some sort of a word counter to count the number of words the user inputs. This is what I have thus far.
import java.text.*;
import java.io.*;
public class test {
public static void main (String [] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String inputValue;
inputValue = input.readLine();
String[] words = inputValue.split("\\s+");
Lets say the users enter the words here is a test run. The program should count 5 values and print out the words as such
here
is
a
test
run
Any help or suggestions on which way to approach this?
for: for loop