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 Java Data Structures - Retired Getting There Type Casting

Chris Rubio
Chris Rubio
1,643 Points

Minute 1:30 HELPPP please

OK so on minute 1:30 he created the new treet and gave it inside the parameter @craig.., and then "Example text"..., and then new Date() ......ok so why after he created it on minute 1:30 does the date not show up? and where is "treet : " coming from ?

2 Answers

Abdullah Alosaimi
PLUS
Abdullah Alosaimi
Courses Plus Student 2,280 Points

That is determined by the toString() method. Take a look at his implementation of this method on previous videos. You can override this method with your own code and decide how the object will be printed as a string.

Chris Rubio
Chris Rubio
1,643 Points

I dont understand? why did he say new Date () and date did come up ? so is the compiler disregard the constructor ?

Abdullah Alosaimi
PLUS
Abdullah Alosaimi
Courses Plus Student 2,280 Points

Every time you create an object the REPL will call toString() method to show you information about the newly created object. You can define this method however you like. He decided not to print the Date.

Here is his code. You can change it and make the REPL print the Date.

public String toString(){
return "Treet: \"" + mDescription + "\" - @" + mAuthor;
}

Good Luck!