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
Ciaran McNally
7,052 PointsWhy can't we add to arrays in Java?
Is there a reason why we can't add to an array in Java? Is it just a nuance of the language or is there a logical reason for it?
1 Answer
Craig Dennis
Treehouse TeacherThe short answer is that memory is allocated at creation time. Not sure where you are in the course yet, but you will see that java.util.List allows for growth much like other languages. In fact, most languages have the same problem, they just put a layer of abstraction on top, so you don't witness the array copying and manipulation, because, you've got better things to be worrying about than memory allocation. ;)
Ciaran McNally
7,052 PointsCiaran McNally
7,052 PointsThanks Craig, got to that part in the course now.