Question: Homework question that I've been having a little trouble with...

I need to have a user input string as a product category. If the user inputs more than one word, I need to take only the first word typed. 

Stipulation: I cannot use 'if' statements. 

Here's what I have so far, but it fails if only one word is typed.

```
Scanner scan = new Scanner (System.in);
System.out.println ("Enter a noun that classifies the"
                    + " type of your product:");

String noun = scan.nextLine();
int n = noun.indexOf(" ");
String inputnoun = noun.substring(0,n);

```

Answer: 
You can use `scan.next()` to get only the first word.
The method `split(String regex)` in the string class will return an array of strings split on the regex string.

```
String test = "Foo Bar Foo Bar"
String[] array = test.split(" ");
//array is now {Foo, Bar, Foo, Bar}

```

From there you can figure out how to get the first word.

Next time you are stuck, the [Java API pages](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html) are very helpful for finding new methods.