Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Efficiency! Changing Course

samuel zaffran
samuel zaffran
24,815 Points

Please, Stuck on the very final task !

Hi, After struggling i almost finish with Java Data Structure, but i can't solve the last task (3/3) in the the last challenge. I don't even understand what am i supposed to do, please, let me achieve it ! Thanks.

1 Answer

Agnieszka Baran
Agnieszka Baran
246 Points

The specific task is asking you to update a video's title to a new one, providing you with the oldTitle (which is actually the current video's title) and a newTitle.

I'd say the solution would be:

  • retrieve a video by its title, you created a method for this purpose in Task #2: videosByTitle(Course course)
  • update the video's title.

Here's a snippet of what I would do:

  public void fixVideoTitle(Course course, String oldTitle, String newTitle) {
    Map<String, Video> videosByTitle = videosByTitle(course);
    // retrieve the video by its old title. The old title is actually the current title
    Video video = videosByTitle.get(oldTitle);
    // update video's title
    video.setTitle(newTitle);
  }

Hope this helps.

samuel zaffran
samuel zaffran
24,815 Points

Hi, Thank you, that helped a lot, i got it !