This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I have got an array and I want to create an other array from that array by specifying start and end index. I receive start value and number of values require from a client. I workout values require by int endValue = valueRequire - startValue; then create an array, of "endValue" length; new Array[endValue]; then put two arrays in a loop and populate the newly created array by reading the original array. This is very very bad, it works for some numbers and fails for others. Can't we just pass in two numbers(start and end) for an array and it gives back a sub array.for example AnyType subArray = actualArray(1,5); Can anyone suggest a better way of doing this. Thanks Khurram.
Joined: Aug 08, 2002
I have found the answer, convert the array into a List and then use List.subList(startValue, endValue);