Shriansh Kumar has Published 324 Articles

Java Program to Recursively Remove All Adjacent Duplicates

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 08:06:38

747 Views

The problem statement states that we have given a String str of length N (where N is an integer) containing alphanumeric characters. We need to recursively remove all adjacent duplicate characters so that the resultant string does not contain any adjacent duplicate characters. We can use a recursive or iterative ... Read More

Java Program to add year to current date using Calendar.add method

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 08:05:46

1K+ Views

The Calendar class of java.util package provides a method with the name add(). This method accepts current date and amount of time as parameter values. If the given amount of time is positive, it will add it to the current date, and in the case of negative time, it will ... Read More

Java StringTokenizer and String Split Example

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 08:04:45

2K+ Views

Both StringTokenizer class and the split() method in Java are used to divide a string into tokens or substrings. However, they are different from each other. The StringTokenizer class does not support regular expressions, whereas the split() method works with regular expressions. In this article, we will see some Java ... Read More

Java Program to Find All Palindromic Sub-Strings of a String

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 07:52:17

1K+ Views

In this problem, we are given a String and our task is to find all palindromic sub-strings of the specified length. There are two ways to solve the problem. The first way is to compare the characters of sub-string from start to last, and another way is to reverse the ... Read More

Java Program to Clear the StringBuffer

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 07:36:08

2K+ Views

On clearing the StringBuffer object, all the characters from the buffer will be removed. In this article, we will write Java program to clear the StringBuffer. StringBuffer is a peer class of String that provides much of the functionality of strings. But, String represents fixed-length, immutable character sequences while ... Read More

Java Program to Display Numbers and Sum of First N Natural Numbers

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 07:34:54

2K+ Views

Natural numbers are all positive integers or whole numbers that range between 1 to infinity. In this article, we will see how to find the sum of the first N natural numbers in Java, where N is the integer up to which we need to add all the numbers starting ... Read More

Java program to find common elements in three sorted arrays

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 07:29:57

1K+ Views

The common elements in three sorted arrays are those elements that occur in all three of them. In this article, we will learn how to find common elements from three sorted arrays in Java. An example of this is given as follows − Example Scenario: Input 1: arr1 = [1, ... Read More

Java program to multiply given floating point numbers

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 07:29:13

1K+ Views

Suppose two floating point numbers are given as operands and your task is to write a Java program to multiply the given numbers. To perform this operation, initialize two float values, multiply and store the result in another float type variable. Float is a datatype in Java which stores numbers ... Read More

Java Program to get day of week as string

Shriansh Kumar

Shriansh Kumar

Updated on 16-Aug-2024 07:28:17

3K+ Views

Some applications that work on calendars require a day name to be displayed for features like scheduling tasks, events or reminders. For this purpose, Java provides various built-in classes and methods including LocalDate, Calendar and SimpleDateFormat. In this article, we will learn how to use these classes and methods ... Read More

Java Program to Find the Perimeter of a Circle

Shriansh Kumar

Shriansh Kumar

Updated on 15-Aug-2024 13:05:46

1K+ Views

For a given circle with radius "r", write a Java program to find the perimeter of that circle. The circumference is also known as the perimeter. It's the distance around a circle. Circumference is given by the formula C = 2𝜋r where, pi/𝜋 = 3.14 and r is the radius ... Read More

Advertisements