Write a program in java to create a doubly linked list containing n nodes.



Write a program in java to create a doubly linked list containing n nodes...

Answer / Dhawal Goyal

Creating a doubly-linked list in Java involves creating inner Node class and using that as a building block for the linked list. Here's a simple implementation:nn```javanpublic class DoublyLinkedList {ntprivate Node head;nn public static class Node {n int data;n Node next, prev;nn public Node(int d) {n data = d;n next = null;n prev = null;n }n }nn public DoublyLinkedList() {n head = null;n }nn // Other methods for adding, removing, and traversing nodes can be added here...n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What does i ++ mean in Java?

1 Answers  


What is OOP's Terms with explanation?

1 Answers  


What is an example of a conditional statement?

1 Answers  


How does system arraycopy work in java?

1 Answers  


What is the alternate of 'Inheritance' ?

4 Answers   CybAge, HCL,


What does %d do in java?

1 Answers  


solve this is my problem byte a=40,byte b=50 both add value is 90 this is with in range of byte... byte range is -128to 127.... why this pgm gives error like type mismatch.... package javapgms; public class byte1 { public static void main(String args[]) { byte a=40,b=50; byte c=a+b; System.out.println(c); } } note : dont use int k... a,b,c are in byte range... mind it..

2 Answers  


What is a map in java?

1 Answers  


How Marker Interfaces are instruct to complete the desired need ?

2 Answers  


Does java arraylist maintain insertion order?

1 Answers  


What is close method? How it's different from Finalize & Dispose?

1 Answers   InfoAxon Technologies,


What is the order of method invocation in an Applet?

1 Answers  


Categories