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 trialWan Nor Adzahari Wan Tajuddin
2,438 PointsWhy am I getting a null?
When I run my code I kept getting This is a new Treet: Treet: "null" - @null"
I've checked my code and I can't seem to find what's wrong with it? Can you find the mistake?
2 Answers
Fahad Mutair
10,359 Pointsyou have error here i just notice that
public Treet(String author, String description, Date creationDate) {
mAuthor = author;
mDescription=description;
mCreationDate=creationDate ;
}
Fahad Mutair
10,359 Pointsyou forgot to put @Override annotation on toString method
@Override
public String toString() {
return "Treet: \"" + mDescription + "\" - @" + mAuthor;
}
Wan Nor Adzahari Wan Tajuddin
2,438 PointsBut as according to the video, Craig's codes works fine even before he put @Override
Wan Nor Adzahari Wan Tajuddin
2,438 PointsWan Nor Adzahari Wan Tajuddin
2,438 PointsOh yes. That's the issue. I made it the other way around! Thank you!