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 Objects (Retired) Meet Objects Welcome Back

Yael P.
Yael P.
2,816 Points

Got false instead of true after lower case at boolean condition

I've used "java-repl" at class, and follow the exact orders of Craig Dennis, but got different results

The code: java> String someWords = "This is a bunch of WORDS!"; java.lang.String someWords = "This is a bunch of WORDS!" java> String lowerWords = someWords.toLowerCase(); java.lang.String someWords = "This is a bunch of words!" java> someWords.contains("words"); java.lang.boolean res1 = false

When Craig got true.. What did I did wrong?

When I wrote java> someWords java.lang.String someWords = "This is a bunch of WORDS!"

Print screen of the case above: https://www.dropbox.com/s/e9e43gx7h1eolue/2015-03-12_1404.png?dl=0

2 Answers

To method "contains" return true to "words", you need use "contains" in "lowerWords" or do it:

someWords = someWords.toLowerCase();