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

Aditya Puri
Aditya Puri
1,080 Points

Didn't work

Here is my example file code- http://prntscr.com/cr93wd Here is my treet file code- http://prntscr.com/cr946v Continued treet file code- http://prntscr.com/cr94ap (screen wasn't big enough :P)

And here is my console result- http://prntscr.com/cr9650 , http://prntscr.com/cr96j4, http://prntscr.com/cr96yu, http://prntscr.com/cr975b (The words marked in color are for reference)

The result repeated, I don't know why...the first time, it didn't display all the words, the second time it did..and at the start some erros were thrown. I don't know what is causing this and am VERY confused..please help

Also side question- why did we convert the treet into lowercase? Doesn't \w account for both lowercase and uppercase letters?

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Hi,

Can you actually paste your code instead of making a screenshots.

I obviously cannot copy/paste your code from image :)

Also there is a fork workspace button in the top right corner on the left from the eye symbol.

It will be even better.

If you have not found, please watch this video 00:30

https://teamtreehouse.com/library/previews-and-snapshots

from this course

https://teamtreehouse.com/library/using-treehouse-workspaces

You could also paste code here, using Markdown , if you can, but forking will much faster

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

I was not able to reproduce unclosed error (

Everything works just fine for me... I compiles, and program runs... Sorry

What did you mean with that circled in colors words... I also do not understand... What exactly is so wrong about them.

And to question

Also side question- why did we convert the treet into lowercase? Doesn't \w account for both lowercase and uppercase letters?

\w splits disregarding of the case, so if you remove toLowerCase it should print somewhat like that

I                                                                   
am                                                                  
doing                                                               
a                                                                   
1M                                                                  
giveaway                                                            
this                                                                
weekend                                                             
If                                                                  
anyone                                                              
wanna                                                               
#win           

and other words

Aditya Puri
Aditya Puri
1,080 Points

the circled words are for reference so that you could connect the screenshots. Also whats wrong with those words? Isn't that what we want? Why would we conver them into lower case?

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Well at this point it actually does not matter if they are lower or mixed-case.

It of course, depends on the purpose of what we are going to do with them afterwards...

But I think later in the course, if I remember correctly, he will want to censor those words. But I may be wrong.

And if we want to censor the words, which is to find "bad" words in Treet, we don't care about the case, so that we don't care whether it was "bad", or "Bad", or "BAD"....

So at this point you can remove toLowerCase - it does not matter. It is not the point of lecture.

He just wanted to show how to split words, that's it.