Hi. I'm learning java through Standford's Open Courseware, and while it's a phenomenal program, and I've been able to work each of the assignments on my own thus far without the teacher contact that is lacking in an open courseware program, I have run into a snag in the last assignment: creating a social network similar to Facebook (on a much smaller scale).
I have the following code in my main method (FacePamphlet.java):
private void addProfile() { String str = profile.getText(); if(!db.containsProfile(str)) { db.addProfile(new FacePamphletProfile("Test Name")); println("Add: new profile: " + db.getProfile(str).toString()); } else { println("Add: Profile for " + db.getProfile(str).getName() + " already exists: " + db.getProfile(str).toString()); } }
You'll note that I'm still in the testing phase since there are println's that are helping me test the functionality that I have so far. Next, in the FacePamphletProfile.java class, I have the following initialization code for the new object:
public FacePamphletProfile(String name) { profileName = name; pStatus = ""; pic = null; friends.clear(); }
Whenever I run the program, there is a Null Pointer Exception thrown when the program reachesnew FacebookPamphletProfile(str)
I can't figure out what's going on. Can anyone help? I would hate to get stuck here at the very end of the course.
Thanks from this humble newbie.