What is LinkedList?

February 8th, 2008 by uCertify Leave a reply »

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:

class LinkedList<E>

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.

Like this article? Share it with others
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.
  • Share/Bookmark
Advertisement

Leave a Reply

uCertify.com | Our Company | Articles | Contact Us | News and Press Release | uCertify India | Entries (RSS)
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD    Cisco Certification: CCNA, CCENT    A+, Network+, Security+ Project+
Oracle Certification: OCP 11g, OCP 10g, OCA 11g, OCA 10g    CIW foundation    EC-212-32,    CISSP    Photoshop ACE CS4    Adobe Flash ACE, PMP, CAPM
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.