Java Java Data Structures Efficiency! Add tags to a course

getting problem in task 3

I don't understand what the question is. Any ideas?

package com.example.model;

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

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

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

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

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

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

  public String getTitle() {
    return mTitle;


1 Answer

Jeremy Hill
Jeremy Hill
24,308 Points

It is asking you to fix the hasTag method. All you do is loop through the tags and compare the item in your loop with the tag that was passed in and if it matches return true otherwise return false.