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 trialnazim khan
1,409 PointsConfused with An array's length is immutable, it cannot be changed?
Hi Im bit confused with the abbve question since we can change the length of the Array using method
public static <T> T[] copyOf(T[] original, int newLength) can anyone please Explain this to me
1 Answer
Seth Kroger
56,413 PointsThat doesn't really change the length of an array. It creates a new array with the new length and copies the old array into it. The old array is unchanged. It's the same way Strings are immutable. You can replace a String with an entirely different one but you can't change the content of either.