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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Kabir Gandhiok](https://secure.gravatar.com/avatar/ffbd4e45b1ae62e06d3343696cc1f1b6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Kabir Gandhiok
12,553 PointsWhy do we create a 0 length treats array in the load method?
I cant seem to understand why a 0 length treats array is created in the load method? Appreciate it if anyone could explain this to me.. thanks!
![Roy Korenblit](https://secure.gravatar.com/avatar/b6dc6f65df466c64394ec011b7be7663?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Roy Korenblit
1,209 PointsSame question. Don't understand how the length of the array can change to the length of the casted object array.
1 Answer
![Pavle Delic](https://secure.gravatar.com/avatar/1fb3e5698ed61d08ef43506a7703ef19?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Pavle Delic
8,088 PointsHi, 0 length array is created so if anything goes wrong with the rest of the code, method have something to return. And second concern is about array changing it's length... It really doesn't.
treets = (Treet[]) ois.readObject();
From this point in the code, "treets" doesn't point to the place in memory previously reserved. It is abandoned now, destroyed. This actually overwrites whatever "threets" was, with newly created array of treets ((Treet[]) ois.readObject()).
Siyuan Ji
3,651 PointsSiyuan Ji
3,651 PointsSame question here ! Can anyone explain why the 0 length array can be replaced by the new array? In previous course the instructor has mentioned that the size of an array cannot be modified, then how does it work here?