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 trialDarin Thompson
5,305 PointsMore than one array element at a time?
after using the
fruit = Arrays.copyOf(fruit, 5);
It seems like you have to add the additional elements one at a time. (i.e. fruit[3] = "someFruit")
Is there a way to add more than one at a time?
Darin Thompson
5,305 PointsJordan, thanks for taking the time to respond. I was thinking something like that was the only way. I ask because I come from a ruby and javascript background where the arrays are more fluid and it's weird learning "an actual programming language" and there being a lot of rules and workarounds to things that I would consider normal.
It wasn't to keep up with the videos, just curious if there was a better way.
Thanks again!
Jordan Powell
Courses Plus Student 5,410 PointsJordan Powell
Courses Plus Student 5,410 Pointsif you're entering strings you could fill it using a for loop and io. This isn't a good practice though because it's not flexible code, but if you're just trying to keep up with the videos this might help since you can just copy and paste it every time. But I wouldn't use it outside of practice.