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
Chris Rubio1,643 Points
please HELP, idk what just happened at runtime , minute 11:30 on the video!
1st - i dont understand what exactly was craig trying to (.sort) ??? was he trying to get alphabetecal order of the tweet ? I am soooooo confused .
2nd - ok so he got an error , sooo im assuming that our code did not work ? why and why not? i understood everything until he compiled at the end of the video.
Yanuar Prakoso15,196 Points
I will try to answer your question:
1st - i dont understand what exactly was craig trying to (.sort) ??? was he trying to get alphabetecal order of the tweet ?
Answer: Craig want to sort Treet (the tweet in Craig's terms of program) but Craig failed to specify how to compare treet to the Java Compiler. This is lead to the reason of your 2nd question.
2nd - ok so he got an error , sooo im assuming that our code did not work ? why and why not?
Yes, he got an error, yes the code did not work...... yet.... As for why basically Craig did not give any specification or ways on how to compare Treets to the Java Compiler. The Compiler then like asking "what is Treet? How do you want me to compare with other Treet you have made?"
Unlike String which the Java compiler already familiar with, Treet is a class object created by Craig. Java only known the basic of it. With String java knows when Craig want an Array of Strings to be sorted it goes natural way as alphabetical order of the Strings. However, Treet is on different case. A treet has author, has the tweet the author wrote, and the date the tweet was uploaded. All of those attributes can be used to sort Treet by Java. Java only need Craig to specify which attribute Craig want to use as sort basis and what is the priority among attributes. For instance Craig can ask java to sort treets according to Date created (or uploaded), if it was uploaded in the same date Craig can then ask Java to sort according to the description alphabetically.
To do all of that, Craig need to modify the code. He need to implement an interface called Comparable. That is exactly what he will do on the next course video. So do not worry, just pass the quiz then watch the next video to get your answer how Craig make the flawed code works.
I hope this can help a little