Java program to delete a new node from the beginning of the doubly linked list17 Mar 2025 | 3 min read In this program, we will create a doubly linked list and delete a node from the beginning of the list. If the list is empty, print the message "List is empty". If the list is not empty, we will make the head to point to next node in the list then; we will delete the first node. ![]() Consider the above example, new was the head of the list. Make head to point to next node in the list. Now, node 1 will become the new head of the list thus, deleting node new. Algorithm
a. display() will show all the nodes present in the list.
Program:Output: Original List: 1 2 3 4 5 Updated List: 2 3 4 5 Updated List: 3 4 5 Updated List: 4 5 Updated List: 5 Updated List: List is empty Next TopicJava Programs |
We can capitalize each word of a string by the help of split() and substring() methods. By the help of split("\\s") method, we can get all words in an array. To get the first character, we can use substring() or charAt() method. Let's see the example...
1 min read
It is a very interesting problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, Accenture, etc. By solving the problem, one wants to check the logical ability, critical thinking, and problem-solving skill of the interviewee. So, in this section, we are going...
3 min read
In this program, we need to find out the maximum height of the binary tree. The height of the binary tree can be defined as the number of nodes between root and a leaf. Maximum height will be the number of levels between root and...
4 min read
Java Program to find Smallest Number in an Array We can find the smallest element or number in an array in java by sorting the array and returning the 1st element. Let's see the full example to find the smallest number in java array. public class SmallestInArrayExample{ public static...
2 min read
Palindromes are fascinating linguistic constructs that have intrigued minds for centuries. In simple terms, a palindrome is a word, phrase, number, or other sequences of characters that reads the same forward and backward. In the realm of programming, creating a program to determine whether a...
9 min read
In this program, we create a doubly linked list and insert a new node in the middle of list. If list is empty, both head and tail will point to new node. If list is not empty, then we will calculate the size of the...
8 min read
In this program, we need to find the frequency of each character present in the word. Picture perfect To accomplish this task, we will maintain an array called freq with same size of the length of the string. Freq will be used to maintain the count of...
3 min read
Java Convert int to String We can convert int to String in java using String.valueOf() and Integer.toString() methods. Alternatively, we can use String.format() method, string concatenation operator etc. Scenario It is generally used if we have to display number in textfield because everything is displayed as a string in...
2 min read
We can reverse each word of a string by the help of reverse(), split() and substring() methods. By using reverse() method of StringBuilder class, we can reverse given string. By the help of split("\\s") method, we can get all words in an array. To get...
1 min read
Java Convert Date to String We can convert Date to String in java using format() method of java.text.DateFormat class. format() method of DateFormat The format() method of DateFormat class is used to convert Date into String. DateFormat is an abstract class. The child class of DateFormat is SimpleDateFormat. It...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India