i this video i'll be creating a linked list using gui in java its implementation will include add first, delete first and delete at any place and display . linked list is a very use full data structure that is dynamic in nature.
implementation of linkedlist is not the scope of the video we only created a gui based linkedlist using netbeans and java.
code to be copied is shown below:
class Node{
int d;
Node next=null;
public Node(int data){
d = data;
}
}
class LinkedList{
Node first=null;
public void addFirst(int data){
Node node = new Node(data);
if(first==null)
first=node;
else{
node.next=first;
first=node;
}
}
public void removeFirst(){
first=first.next;
}
public void delete(int value){
Node temp=first;
Node temp1=first;
if(first.d==value){
first=temp.next;
temp=null;
}
else{
while(temp.next!=null){
if(temp.next.d==value){
break;
}
temp = temp.next;
if(temp.next.next==null){
temp1=temp;
}
}
if(temp.next == null&&temp.d == value){
temp1.next=null;
temp=temp1;
}
else{
Node current=temp;
Node center=temp.next;
current.next=center.next;
center.next=null;
}
}
}
public String Display(){
Node current=first;
String output = "Head --- ";
while(current!=null)
{
output += current.d;
if(current.next != null)
output += " --- ";
current=current.next;
}
return output;
}
}
On this page of the site you can watch the video online Java: Create LinkedList using GUI with a duration of hours minute second in good quality, which was uploaded by the user CODE ZERO 09 December 2020, share the link with friends and acquaintances, this video has already been watched 4,627 times on youtube and it was liked by 78 viewers. Enjoy your viewing!