copying portion of object array in Java -
If I have an object array in Java then I thought about making it for a loop Is there another way to use Java built in some library? If so, will it be more or less efficient than the proposed loop? You can use the sample: method car [] a = {0,2,2,3 , 4, 5, 6, 7}. How do I copy this array from 2 to 7?
car [b] = new car [a.length - 2]; For (inti = 2; i & lt; a.length; i ++) {b [i - 2] = a [i]; }
copyOfRange to copy some of the categories
arrays class
Arrays.copyOfRange (b, 2, 7);
copyOfRange (T [] from the original, int, int)
Comments
Post a Comment