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

iftekhar uddin
4,194 PointsException in thread "main" java.lang.NullPointerException
Problem: I'm getting this error
Exception in thread "main" java.lang.NullPointerException
at com.teamtreehouse.model.SongBook.addSong(SongBook.java:14)
at Karaoke.main(Karaoke.java:14)
I have looked at SongBook.java line 14 and unless I'm blind it's exactly how it is with craig's code in the video "building the model"
thanks for taking the time reading and responding to my question. Much Appreciated.
1 Answer

Ken Alger
Treehouse Teacheriftekhar;
In SongBook.java
you have
public void SongBook() {
mSongs = new ArrayList<Song>();
}
Remove the void
from that method, as in the videos, and your code works great. Remember that in Java constructors don't have explicit return types in their method signatures.
Happy coding,
Ken
iftekhar uddin
4,194 Pointsiftekhar uddin
4,194 PointsOh my god I feel so stupid XD. I tunnel visioned on that line so much that I didn't even realize that constructor was messed up. Thanks =)
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherDon't feel stupid. That's part of the learning process.