Singly LinkList in java

Singly LinkList in java
As mentioned in the previous post LinkList is a very vital data structure which are declared dynamically. Its of two types Singly and Doubly. Today we are going to discuss on singly link list. Singly Link list consists of two parts the value part and the reference part. The first part or the value part stores the value of node input by user. The second part or the reference part stores the referring value of the next node. This form of link list can be very useful to implement data structures such as stack, queues;etc.
     Here the first node is commonly known as the start node. It points to the first node storing values. The last node is commonly known as last. As it is the last node in the whole list so it doesn't have any node to point towards and hence it contains a null value in the reference part.
     In case of link list if asked in examination we need to just write the function because the programs are too long and hence just to check the caliber one is asked to write the function only.
     It has three basic operations:
  1. Adding
  2. Displaying
  3. Removing/Deleting 

Adding a new node:

   In case of add we first of all will take the input of the first node both its value as well as the reference value. And one important thing to note every next(reference) value must be initially declared with null then comes a do while loop which encounters with a 'k' value means it will take entry until the user wants to have the node to be generated. In the loop we will first take the entry of the info part then the reference will be declared with a null and will copy its initial reference value to the node added previously. After all entry we will declare a call function of it in the main part.
public static void create(link node){
        int k;
     Scanner sc=new Scanner(System.in);
     System.out.println("Enter the value of node:");
     node.info=sc.nextInt();
     node.next=null;
   do{
     link temp=new link();
     System.out.println("Enter the temp node:");
     temp.info=sc.nextInt();
     temp.next=null;
     node.next=temp;
     node=temp;
     System.out.println("Enter 0 to continue and 1 to exit:");
     k=sc.nextInt();
       }while(k==0);

Linked List

Linked List
Linked List in java is a set of two information. The first part contains the value and the second part consists of the reference of the next node. The first node is better known as the start node. The last node of it consists of null because the last node need not to refer to any node. It inherits the Abstract class and implements a list form. We can better denote it with a train, where start is the engine and the last node null value is the cross mark of the trains last compartment. LinkList allocates dynamically which results to consumption of space as well as time. Avoids haphazard storage of values.

Few points to be noted:
  • It can contain duplicate elements
  • It maintains order of insertion
  • It is a non-synchronized form
  • Scene there is no shifting so compiling time is less
  • It can either be used as a link-list, stack or queue
LinkList are of two types :
  1. Singly LinkList
  2. Doubly LinkList
Singly LinkList is a set of two parts one is the information part which stores the value inserted by user for the node and the other part is the reference part which refers to the next node. It is an one sided list. The first link is popularly known as start followed by the first valued node.

Doubly LinkList is the set consisting of three parts the first part contains the reference of the previous node, the second part consists of the info part inserted by the user and the third and the last part consists of the reference value referring to the next node available.
Method to declare a LinkList is: 
public class LinkedList extends AbstractSequentialList implements ListDequeCloneable, Serializable