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 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 !