How to create a linked list in Java

0

 


In this post we will see how can we create a linked list in java.




class Node
{
int Data;
String str;
Node next;
Node(String str,int Data)
{
this.str=str;
this.Data=Data;
this.next=null;
}
}

class HindiCodingCommunity
{
public static void main(String args[])
{
Node head1=new Node("A",1);
Node head2=new Node("B",2);
Node head3=new Node("C",3);
head1.next=head2;
head2.next=head3;
System.out.println("Name :- "+head1.str+"\nNumber :- "+head1.Data);
}
}


Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !