Krantik Chavan has Published 295 Articles

C++ Program to Implement Extended Euclidean Algorithm

Krantik Chavan

Krantik Chavan

Updated on 25-Apr-2025 15:31:16

2K+ Views

The extended Euclidean algorithms find the greatest common divisor(GCD) of two numbers in the form of ax + by = gcd(a, b). This expression is also known as Bezout's Identity. The extended Euclidean algorithm is an extension of the Euclid algorithm that is also used to find the GCD of ... Read More

Java program to sort string stream with reversed comparator

Krantik Chavan

Krantik Chavan

Updated on 23-Nov-2024 03:58:06

505 Views

In this article, we will learn how to sort a stream of strings using a reversed comparator in Java. Java 8 introduced the Stream API, which allows powerful operations like sorting using custom comparators. Java Comparator A Comparator is a functional interface in Java that defines custom sorting logic. It ... Read More

Java program to get the number of minutes in this duration

Krantik Chavan

Krantik Chavan

Updated on 18-Nov-2024 22:30:42

286 Views

In this article, we calculate the number of minutes in a given duration using Java. The Duration class can perform time-based calculations like hours, minutes, days, etc.. and easily convert between these units. Using the toMinutes() method you will be able to get the number of minutes from a given ... Read More

Java program to create duration from seconds

Krantik Chavan

Krantik Chavan

Updated on 15-Nov-2024 18:43:20

145 Views

In this article, we will learn how to create a Duration object in Java based on different time units like days, hours, milliseconds, and minutes, and then convert them into seconds. The Duration class in Java is part of the java.time package and is used to represent a duration of ... Read More

Java program to disable the first item on a JComboBox

Krantik Chavan

Krantik Chavan

Updated on 14-Nov-2024 17:40:11

922 Views

In this article, we will learn to disable the first item on a JComboBox using Java. This setup is useful for applications where you want to show a placeholder as the first item and prevent it from being chosen, so users must select a valid option. We will be using ... Read More

Java program to display a webpage in JEditorPane

Krantik Chavan

Krantik Chavan

Updated on 13-Nov-2024 12:20:34

678 Views

In this article, we will learn how to display a webpage in JEditorPane using Java. The program will load a specified webpage, and display it within a GUI window. If the connection to the webpage fails, a message will appear indicating the connection issue. This setup can be useful for ... Read More

Java program to fill elements in a long array

Krantik Chavan

Krantik Chavan

Updated on 05-Nov-2024 22:03:17

501 Views

In this article, we will learn how to fill elements in a long array in Java using the Arrays.fill() method. This method allows us to assign a specific long value to all elements of the array. The Arrays.fill() function is a simple way to initialize or overwrite the values in ... Read More

Java program to sort a list placing nulls in the end

Krantik Chavan

Krantik Chavan

Updated on 30-Oct-2024 18:44:59

619 Views

In this article, we will learn how to sort lists containing null values in Java and ensure these nulls are kept at the bottom while upper elements remain in order. This can be done using Comparator.nullsLast, which sorts the non-null elements and places all null elements at last. Problem Statement ... Read More

Java program to get the reverse of an Integer array with Lambda expressions

Krantik Chavan

Krantik Chavan

Updated on 29-Oct-2024 18:51:17

635 Views

In this article, we will learn to get the reverse of an Integer array with Lambda expressions in Java. By utilizing the Arrays.sort() method along with a custom comparator defined as a lambda expression, we can efficiently reorder the elements of the array in descending order. Lambda expressions are a concise ... Read More

Java program to get date for all the days of the current week

Krantik Chavan

Krantik Chavan

Updated on 18-Oct-2024 11:57:36

873 Views

In this article, we will learn to get date for all the days of the current week using Java. We will use the java.time package to get the current date and calculate the dates for the rest of the week based on the current day.  Steps to get date for all ... Read More

1 2 3 4 5 ... 30 Next
Advertisements