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

I can not get SongBook.java to compile.

This is my second attempt. I started over with a new workbook and still every time I run javac SongBook.java I receive the error "can not find symbol" that points at each location that refers to the Song class.

Here is the SongBook Class

package com.teamtreehouse.model;

import java.util.List;
import java.util.ArrayList;


public class SongBook {
  private List<Song> mSongs;

  public SongBook(){
    mSongs = new ArrayList<Song>();
  }

  public void addSong(Song song){
    mSongs.add(song);
  }

  public int getSongCount(){
    return mSongs.size();    
  }

}

And here is the Song class

package com.teamtreehouse.model;

public class Song{
  private String mArtist;
  private String mTitle;
  private String mVideoUrl;

  public Song(String artist, String title, String videoUrl){
    mArtist = artist;
    mTitle = title;
    mVideoUrl = videoUrl;
  }

  public String getArtist(){
    return mArtist;
  }

  public String getTitle(){
    return mTitle;
  }

  public String getVideoUrl(){
    return mVideoUrl;
  }
  @Override
  public String toString(){
    return String.format("Song: %s by %s", mTitle, mArtist);
  }
}
Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Brooks, I can't see a Song class, only two identical SongBook classes.

2 Answers

I apologize. The question has been edited.

So, would there be a reason this would fail if I created my file structure with from the terminal rather than right-clicking on the window? I redid it and that is the only thing I did differently and it works now.