Let's say I initialize an ArrayList using the following code:
ArrayList fib = new ArrayList();
fib.add(18);
fib.add(23);
fib.add(37);
fib.add(45);
fib.add(50);
fib.add(67);
fib.add(38);
fib.add(88);
fib.add(91);
fib.add(10);
What if I want to reference a specific index of the array. I don't want what's in the index. I want the index itself. I know this seems redundant, but it spills into another code.
To reference what's IN the index, I would do this:
fib.temp(4);
and it would yield
50
What if I want what index it is?
Listis 0 indexed, wouldn't it return50...?tempandfibalmost interchangably - and then referring to your list as an array, which it certainly isn't... A lot of the discipline of software engineering is paying attention to the details. Please take more care in your next question.ArrayListwithArray, what you want,Arraycan do that for you...fib.get(3), where4is a 0 based index, returns 45