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
jay angCourses Plus Student 679 Points
System.arraycopy(); the last '2'?
in the System.arraycopy(fruit, 0, biggerfruit, 0 , 2); what does the '2' means? (the last one)
The last argument is the length. More simply put it is the number of items you want to copy from one array to the other.
Robert Stamate13,227 Points
As andren said the last argument is length. In order to make it more understandable I got by this:
System.arraycopy(fruit, 0, biggerfruit, 0 , fruit.lenth); // Instead of two (2) I use the current array length;
And if I use the java.util.Arrays I got like this:
fruit = Arrays.copyOf(fruit, fruit.length + 1); // and it will always add me one more spot in my Array at the end;