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!

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 Refresher

Taylor Quinn
Taylor Quinn
20,003 Points

For the method on a string that compares it to another string is the method .equals?

I have been using .equals for the question but have not been getting it right. What am i doing wrong?

4 Answers

Christopher Augg
Christopher Augg
21,223 Points


The question is not asking you to compare the Strings. You would use .equals if that were the case. However, it asks the following:

"Which method on String will allow you to check if a String is part of another."

String someWords = "These are words";


Do you recall what to use to see if a String contains another String? i.e. Does someWords contain "words"?

Please let me know if this helps.



4,322 Points

Can someone explain the method of contains stands for? I Haven't seen its introduction in earlier videos or might just skipped that.

me too I didnt come across such teach...i was wondering when did craig teach that contain parts LOL

Taylor Quinn
Taylor Quinn
20,003 Points

.contains.....So simple yet still got by me. Thank you

i didn't see this either.