"CSS Basics (2014)" was retired on July 12, 2021. You are now viewing the recommended replacement.

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

Enyang Mercy
PLUS
Enyang Mercy
Courses Plus Student 2,339 Points

ArrayList/LinkedList a method with that return list of links

STUCK!!!! I can't figure out where i have gone wrong. Any suggestion with the right code

com/example/BlogPost.java
package com.example;
import java.util.Arraylist;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

public class BlogPost implements Comparable<BlogPost>, Serializable {
  private String mAuthor;
  private String mTitle;
  private String mBody;
  private String mCategory;
  private Date mCreationDate;

  public BlogPost(String author, String title, String body, String category, Date creationDate) {
    mAuthor = author;
    mTitle = title;
    mBody = body;
    mCategory = category;
    mCreationDate = creationDate;
  }

  public int compareTo(BlogPost other) {
    if (equals(other)) {
      return 0;
    }
    return mCreationDate.compareTo(other.mCreationDate);
  }

  public String[] getWords() {
    return mBody.split("\\s+");
  }

  public String getAuthor() {
    return mAuthor;
  }

  public String getTitle() {
    return mTitle;
  }

  public String getBody() {
    return mBody;
  }

  public String getCategory() {
    return mCategory;
  }

  public Date getCreationDate() {
    return mCreationDate;
  }
  public List<String> getExternalLinks () {
    List<String> link = new ArrayList<String> ();
    for (String word : getWords()) {
      if (word.startsWith("http")) {
        link.add(word);
      }
    }
    return link;
  }
}

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I received your request for assistance. First, let me say that you're doing terrific!

Now to the problem. You're either going to love or hate this answer. You have a typo in your import statements.

You typed:

import java.util.Arraylist;

But you meant to type:

import java.util.ArrayList;

Note the capitalization of the "L" in "List" in the second version. When I change that one letter, your code passes the challenge. Well done! :sparkles:

Hi there,

Your errors show that ArrayList is unknown - that's because your import doesn't have a capital L in it. Change that and your code is fine.

Steve.

:+1: