String[] colors = {"yellow", "green", "blue"};
LinkedList ll = new LinkedList<>(Arrays.asList(colors));
ll.add("red");
ll.addFirst("black");
ListIterator listIterator = ll.listIterator();
while (listIterator.hasNext()){
System.out.println(listIterator.nextIndex() + " = " +listIterator.next());
}
colors = ll.toArray(new String[ll.size()]);
System.out.println(Arrays.toString(colors));
LinkedList
ll.add("red");
ll.addFirst("black");
ListIterator
while (listIterator.hasNext()){
System.out.println(listIterator.nextIndex() + " = " +listIterator.next());
}
colors = ll.toArray(new String[ll.size()]);
System.out.println(Arrays.toString(colors));
Комментариев нет:
Отправить комментарий