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 trialbkprojects
15,539 PointsWhy did we change the return-type of the getWords() - method?
In our private method getWordsPrefixedWith(String prefix) we go through every word of the ArrayList that is returned by getWords(), but why did we change the return-type of getWords() in the first place? I struggle to see the advantage of 'for-each-looping' through an ArrayList vs. an Array (old getWords()-method returned String[] ). It should have O(n) in both cases, shouldn't it?
1 Answer
Tee Abdul
8,411 PointsI think it was just for consistency (good coding practice). The other three methods (getMentions, getHashTags, and getWordsPrefixedWith) all return ArrayLists.