Use 0 as the starting index when searching from the first element to the last
Use theArray.length-1 as the starting index when searching from the last element to the first
Type: Posts; User: Norm
Use 0 as the starting index when searching from the first element to the last
Use theArray.length-1 as the starting index when searching from the last element to the first
It's better to start at theArray.length-1. That will be the index to the last element in the array.
It's better NOT to hardcode numbers like array lengths in a program.
When iterating through an array with a standard for loop, it's better to use the array's .length field and not hard code the size of the array:
for(int i=0; i<theArray.length; i++) {