Java Programming: Lesson 63 - List Iterators
PLEASE SUBSCRIBE!!!
In the previous lesson (https://youtu.be/4jHQuaMOnOU), we learned about enumerations, which are similar to iterators but do not offer a remove( ) method. Inversely, in this video we will study an object which is even stronger than a regular iterator. It can traverse a list in both directions. We will discuss this in more depth in the next video. https://youtu.be/IqkZmd8EvVg
An enumeration is like an iterator, but with longer method names and no remove method. You can call an enumeration on a Vector or Stack, but not on other data structures. You're better off importing Iterator and creating an Iterator object on a particular data structure. But for enumerations:
1. import java.util.Enumeration;
2. create an Enumeration object on your data structure
3. while( enumeration.hasMoreElements( ) )
4. System.out.println( enumeration.nextElement( ) )
A list iterator is like an iterator, but with more methods available. You can call a list iterator on an ArrayList, LinkedList, Vector, or Stack, but not on other data structures.
1. import java.util.ListIterator;
2. create a ListIterator object on your data structure
3. while( listIterator.hasNext( ) )
4. System.out.println( listIterator.next( ) )
5. while( listIterator.hasPrevious( ) )
6. System.out.println( listIterator.previous( ) ) //can traverse a list iterator in BOTH directions, unlike a traditional iterator as studied previously. Better than an iterator, way better than an enumeration...
The point is that
enumerations: can check for a next element, can return it if there is one
iterators: can ALSO remove elements from the underlying data structure
list iterators: can ALSO add elements to the underlying data structure, and can ALSO traverse a vector or stack in the opposite direction (e.g. myStack.hasPrevious( ) or myVector.previous() )
0:29 Review of Stacks and Iterators
7:55 Review of Enumerations
11:07 NEW: List Iterators
If justice still hasn't been done to the topic of list iterators, I provide another example in lesson 70: https://youtu.be/Vr9ZVFrb4zk (and in other videos around there)
In the next video, we will see something called hash tables, which is basically the same as reviewing hash maps. https://youtu.be/IqkZmd8EvVg (but write Hashtable instead of HashMap in your import, your declaration, and your initialization. That's it.)
Thanks for watching, and PLEASE SUBSCRIBE!!!
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java Programming: Lesson 63 - List Iterators», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.