0

How to increment an array? And how to get a value of incremented array?

9/29/2019 3:53:01 AM

Jilani Khokhar

2 Answers

New Answer

+1

~ swim ~ thx man

0

Given an array int [] arr = {1,2,3,4,5,6,7}; arr[0] = 1, arr[1] = 2, arr[2] = 3, arr[3] = 4 etc.. Arrays are accessed using indexes. The index starts from 0 i.e first element is at index 0, to access it you write arr[0]. To access all the elements of the array you can run a loop and index it using a variable say idx whose value will vary from 0 to array length (exclusive) (if array has 10 elements then the last valid index is 9)