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 Data Structures Exploring the Java Collection Framework ArrayLists

Diego Marrs
Diego Marrs
8,243 Points

Question about challenge.

I have a few questions about this challenge:

private List<String> getExternalLinks() {
    List<String> result = new ArrayList<String>();
    for (String word : getWords()) {
      if (word.startsWith("http")) {
    return result;
  1. Why should the method be public?
  2. How come we don't use getBody()?

Also, i'm still a little confused on lists vs. arrays.

Help is appreciated!

1 Answer


1) if it is private then it would not be available from other classes. See https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html for more detail.

2) getBody() returns the text, but to find http it's easier to first split the body text into separate words, which is what getWords() does.

3) List is an interface, ArrayList is a class that implements that interface. You cannot create List objects. You can create ArrayList objects.