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

totally use that videosByTitle

I dont get what I am missing here... help please :)

It is the final step, but keeps saying that it does not recognise the videosByTitle method that I just defined...

package com.example.model;

import java.util.List;

public class Course {
  private String mName;
  private List<Video> mVideos; 

  public Course(String name, List<Video> videos) {
    mName = name;
    mVideos = videos;

  public String getName() {
    return mName;

  public List<Video> getVideos() {
    return mVideos;

package com.example.model;

public class Video {
  private String mTitle;

  public Video(String title) {
    mTitle = title;

  public String getTitle() {
    return mTitle;

  public void setTitle(String title) {
    mTitle = title;

import com.example.model.Course;
import com.example.model.Video;

import java.util.Map;
import java.util.HashMap;
import java.util.List;

public class QuickFix {

  public void addForgottenVideo(Course course) {

    Video video = new Video ("The beginning Bits");

    List<Video> videoList = course.getVideos();
    videoList.add(1, video);


  public void fixVideoTitle(Course course, String oldTitle, String newTitle) {

    Map<String, Video> videos = videosBytitle(course);
    Video video = videos.get(oldTitle);


  public Map<String, Video> videosByTitle(Course course) {

    Map<String, Video> titleToVideo = new HashMap<>();
    List<Video> videos = course.getVideos();

    for (Video video: videos) {
      titleToVideo.put(video.getTitle(), video);

    return titleToVideo;


1 Answer

Hi Ricardo,

My code looks similar:

  public Map<String, Video> videosByTitle(Course course) {
    HashMap videoMap = new HashMap<String, Video>();
    for(Video video : course.getVideos()){
      videoMap.put(video.getTitle(), video);
    return videoMap;

What you've not done is import the HashMap! Just add that and your code works fine.