Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired Organizing Data Splitting Strings

Workspaces don't support Java 8+ streams?

I'm trying to use a stream to print out all of the words in the description and it is not working (code below):

import java.util.stream;
//...
blogPost.getDescriptionWords.stream().forEach(System.out::println);

This is the error I'm getting:

Example.java:2: error: cannot find symbol                                                                                                              
import java.util.stream;                                                                                                                               
                ^                                                                                                                                      
  symbol:   class stream                                                                                                                               
  location: package java.util                                                                                                                          
Example.java:10: error: cannot find symbol                                                                                                             
    blogPost.getDescriptionWords().stream().forEach(System.out::println);                                                                              
                                  ^                                                                                                                    
  symbol:   method stream()                                                                                                                            
  location: class String[]                                                                                                                             
2 errors

UPDATE:

I solved the problem. My mistake was treating an array like it was a list. Here is what I should have done:

import java.util.Arrays;
//...
Arrays.stream(blogPost.getDescriptionWords()).forEach(System.out::println);

Also, I didn't need to import "java.util.stream", I guess streams are just in Java by default now.