Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Bi-Directional Iterators They are Cursors which supports Both Forward Direction and Backward Direction iterations. For instance, ListIterator are *****Bi******-Directional Iterators.
- Kiran
Eventhough, we add one element via listIterator to arrayList during iteration, it will not go infinite loop. Can anyone explain logic? ArrayList arrayList = new ArrayList(); arrayList.add(12); ListIterator listIterator = arrayList.listIterator(); while(listIterator.hasNext()){ Integer input =listIterator.next(); System.out.println(input);//Prints 12 listIterator.add(input+1); }
- Praveen
Hi The below line of code does not go infinite loop. Can anyone explain why? ArrayList arrayList = new ArrayList(); arrayList.add(12); ListIterator listIterator = arrayList.listIterator(); while(listIterator.hasNext()){ Integer input =listIterator.next(); System.out.println(input);//Prints 12 listIterator.add(input+1); }
- Praveen
The explanation of ListIterator is wrong at ListIterator.hasPrevious() section. You are telling that after executing namesIterator.hasPrevious(); namesIterator.previous(); The cursor will point to last element in the linked list but it is wrong. When you execute this statement you gill get runTimeException as NoSuchElementException. This is because after calling listIterator() function, the cursor will point at the first element of the list. If we want the cursor to point to the last element of List, explicitly we have to iterate throughout the list to reach end of the list, after that we would be able to point to last element of list.
- Vikas Kumar