Wednesday, 11 April 2018

LinkList (Java)

Java Linked List class uses doubly linked list to store the elements.

The important points about Java Linked List are:
  • Java Linked List class can contain duplicate elements.
  • Java Linked List class maintains insertion order.
  • Java Linked List class is non synchronized.
  • In Java Linked List class, manipulation is fast because no shifting needs to be occurred.
  • Java Linked List class can be used as list, stack or queue.                                                            Syntax:-                                                                                                                                                      Link List<string>name=new Linked List<string>();                                                                                  {
………………………..    (Description)                                                                                                                                        }                                                                                                                                                                                Example:-
Public Class MyClass
pulic static void main(string[] args)
LinkList<string>name=new LinkedList<string>();
name.add(“ABC”);      //Add a name in LinkList
name.add(“PQR”);     //Add a name in LinkList
name.add(“XYZ”);     //Add a name in LinkList
name.addfirst(“Jack”);     //Add First name in LinkList.
name.addlast(“Zack”);     //Add Last name in LinkList.
name.removelast();            //Remove  First name in LinkList.
name.removefirst();         // Remove Last name in LinkList.
name.clear();                    //Delete all the data in LinkList.
name.add(index,”element”);      //This is a syntax for add a variable of particular position in LinkList.
name.remove(2);     // Remove a variable of particular position in LinkList
name.set(1,”a”);  //Change a name as particular index.

1 comment:

Codecademy Code Foundations

Popular Posts


Android (23) AngularJS (1) Assembly Language (2) Books (10) C (75) C# (12) C++ (81) Course (1) Data Strucures (4) Downloads (1) Engineering (13) flutter (1) FPL (17) Hadoop (1) HTML&CSS (38) IS (25) Java (87) Leet Code (4) Pandas (1) PHP (20) Projects (17) Python (264) R (69) Selenium Webdriver (2) Software (14) SQL (27)