Java Java Data Structures Efficiency! Add tags to a course

I'm trying to initialize mTags in the constructor but I'm not sure where to get the values to put in the mTags set.

I'm thinking maybe I have to pass in a String "tag"???

package com.example.model;

import java.util.List;
import java.util.Set;

public class Course {
  private String mTitle;
  private Set<String> mTags;

  public Course(String title) {
    mTitle = title;
    // TODO: initialize the set mTags
    mTags = ;

  public void addTag(String tag) {
    // TODO: add the tag

  public void addTags(List<String> tags) {
    // TODO: add all the tags passed in

  public boolean hasTag(String tag) {
    // TODO: Return whether or not the tag has been added
    return false;

  public String getTitle() {
    return mTitle;


1 Answer

Seth Kroger
Seth Kroger
56,361 Points

You don't need to pass in any tags, but it does need to be initialized with a default constructor. This will result in an empty set. Don't forget that you have to pick a specific implementation of Set and and the import statement for it.