Skip to content
Brian Milton edited this page Jul 23, 2013 · 2 revisions

.add(index,Element) or .add(Element)

Element can be any item to be added to the list. You can have objects, strings, numbers or a mixture of these in the list (be careful as mixed Element type sill not correctly sort).

When called with just an Element, the specified Element is added at the tail of the list.

When an index is supplied, then the Element is inserted at the specified index (zero-based).

var lst = new LinkedList();

lst.add("A"); // List now contains "A".
lst.add("B"); // List now contains "A", "B".
lst.add("D"); // List now contains "A", "B", "D".

lst.add(2, "C"); // List now contains "A", "B", "C", "D".
Clone this wiki locally