Professional Documents
Culture Documents
1a.) Java Program To Create A Singly Linked List With Some Node Containing Names of Cities in Nepal and Display All Elements of List..
1a.) Java Program To Create A Singly Linked List With Some Node Containing Names of Cities in Nepal and Display All Elements of List..
) java program to create a singly linked list with some node containing names of cities in Nepal
and display all elements of list..
=
class Node{
String data;
Node next;
class SinglyLinkedList
{ Node head;
SinglyLinkedList(Node head)
this.head=head;
n1.data="Kathmandu";
n2.data="lalitpur";
n3.data="Bhaktapur";
n4.data="Dolakha";
n1.next=n2;
n2.next=n3;
n3.next=n4;
n4.next=null;
while(tempHead!=null)
System.out.println(tempHead.data);
tempHead=tempHead.next;
System.out.println("\nlab no:1a\nName:Anurag\nRollno:18000-36");