LinkedList is a class that extends the AbstractSequentialList class and implements the List and Queue interfaces. LinkedList is a generic class. The class declaration is given below:
Here, E specifies the type of objects that the list will hold.
It defines the following two constructors:
- LinkedList(): It builds an empty linked list.
- LinkedList(Collection <?extends E >c): It builds a linked list that is initialized with the elements of a collection c
The LinkedList class defines the following methods for manipulating lists. These are as follows:
- void addFirst(E obj): This method inserts an element at the beginning of the list.
- void addLast(E obj): This method inserts an element at the end of a list
- E getFirst(): This method is used to retrieve the first element from the list.
- E getLast(): This method retrieves the last element from the list.
- E removeFirst(): This removes the first element from the list.
- E removeLast(): This method removes the last element from the list.
Here, obj specifies the item.
- Get certified in first attempt download master-ciw-enterprise-developer - Master CIW Enterprise Developer simulation.
- Pass SUN scbcd - SCBCD
- Best exam simulation SUN scdjws download free trial.
- Download free practice test for SUN SCJA exam.
- Pass SUN scjp - SCJP
- Download free practice test for scjp-5-0 SCJP 5/6 exam.
- Download free practice test for scmad SCMAD exam.
- Click here to get free scwcd SCWCD exam practice questions.
- Click here to download CX310-019 test study guide and practice question.
- Pass Java 5.0 in first attampt.
- Become SUN SCJP 6.0 certified.
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.