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 trialSteve Lewin
6,784 PointsstateCodesIgnoreBlanks FAILED and not sure why
I've tried the following solution and the test is still failing. Any idea why?
public static List<String> getStateCodesFromRecords(List<HousingRecord> records) { // TODO: Open a stream on records // TODO: Map the stream to the state code // TODO: Filter out any records without a state // TODO: There are duplicate state codes in the records, make sure we have a unique representation // TODO: Sort them alphabetically // TODO: Collect them into a new list. //return Collections.emptyList(); return records.stream() .map(HousingRecord::getState) .filter(Objects::nonNull) .distinct() .sorted() .collect(Collectors.toList());
1 Answer
Steve Lewin
6,784 PointsNever mind. I found the answer. It looks like they are looking for the following filter: .filter(state -> !state.isEmpty())