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

Arnold Rosario
16,357 PointsSerialization: What does the Treet[] treets = new Treet[0] mean?
In the Serialization video, Craigs writes Treet[] treets = new Treet[0];
I don't understand why he wrote new Treet[0]? What does that mean? I am only familiar with creating arrays by saying Treet[] treets = {treet1, treet2, treet3};

Craig Dennis
Treehouse TeacherIf you ask a question from the video it will be properly categorized...adding an answer too.
1 Answer

Craig Dennis
Treehouse TeacherArray sizes are locked at creation. This is how you state how large the array should be so if I you write:
String[] words = String[3];
It will be a 3 element array of null
values.
Make sense?

Arnold Rosario
16,357 PointsThanks again, you tha man!

Arnold Rosario
16,357 PointsActually, just to be sure.
So in the video's example: Treet[] treets = new Treet[0]; That means create a new Treet array with 1 element? Since arrays are 0-indexed?

Arnold Rosario
16,357 PointsAlso, wouldn't String[3] create a 4 element array of null values? Since you'll have words[0], words[1], words[2], words[3]?

Craig Dennis
Treehouse TeacherNope that's actually the size. The Treet array has 0 elements. I know...confusing :/
Arnold Rosario
16,357 PointsArnold Rosario
16,357 PointsAlso, how do I post questions into the correct category?