Compare Two Dates in Java

Vivek Verma
Updated on 20-Jun-2025 17:05:55

82K+ Views

In Java, we can compare two dates using the compareTo() method of the Comparable interface. This is a common way to compare two dates, and this method returns an integer value based on which you can specify which date occurs before, after, or if it is equal. Here are the return values by this method, based on which you verify the date appearance: ... Read More

Concatenated String with Uncommon Characters in Python

Yaswanth Varma
Updated on 20-Jun-2025 16:37:14

944 Views

In Python, Strings are one of the commonly used data types that are used to store sequences of characters. In this article, we are going to learn to concatenate strings with uncommon characters in Python. The uncommon characters are the characters that appear in one string but not in the other string. For example, if str1="ABC" and str2="BCD", the uncommon characters are 'A' and 'D', and the concatenated result is "AD". Using set.symmetric_difference() Method The python set.symmetric_difference() method is used to return the new set that contains the elements that are in either of the sets, but ... Read More

Iterate Over Multiple Lists Simultaneously in Python

Yaswanth Varma
Updated on 20-Jun-2025 16:23:35

346 Views

In this article, we are going to learn how to iterate over multiple lists simultaneously. It is useful when the lists contain related data. For example, one list stores names, another stores genders, and the last one stores ages. By iterating over these lists simultaneously, we can access the necessary details of a single person. Iterating Over Multiple Lists using zip() Function The Python zip() function is a built-in function used to combine the elements from two or more iterator objects (such as lists, tuples, etc) and returns the result. The resultant iterator object contains tuples where the ith tuple ... Read More

Find Common Elements in Three Sorted Arrays in Python

Yaswanth Varma
Updated on 20-Jun-2025 12:52:42

766 Views

The given task is to find the common element in three sorted arrays. Input Output Scenario Following is an input-output scenario - Input Arrays: array1 = [1001, 1004, 1007, 1009, 1015, 1020] array2 = [1002, 1004, 1009, 1013, 1015, 1022] array3 = [1000, 1004, 1009, 1015, 1021] Output: [1004, 1009, 1015] This is useful in multiple scenarios, for example, if we are filtering mutual friends of three different users in apps like Facebook or comparing product availability in three different e-commerce applications on a third-party website. We are filtering elements that are common in multiple ... Read More

Reverse Bits of a Positive Integer in Python

Yaswanth Varma
Updated on 19-Jun-2025 18:23:53

2K+ Views

In Python, every number is represented internally as a sequence of binary digits, known as bits. In this article, we are going to learn how to reverse the bits of a positive integer number. Reversing the bits of a Positive Integer Number If we reverse bits of an integer value, we are flipping the order of its binary digits such that the least important bit becomes the most important and vice versa.  The Python bin() Function: The Python bin() function accepts an integer value and converts the given integer to its binary representation. Following is the syntax of this ... Read More

Check If a Given Class is an Anonymous Class in Java

Shriansh Kumar
Updated on 19-Jun-2025 16:15:26

194 Views

The type of nested class that has no name is called an anonymous class. Before diving into a Java program to check if a given class is an anonymous class, we need to understand what is a nested class. Let's discuss this in detail. What is a Java Nested Class? A class created within another class in Java is called a nested class. We know that we cannot declare a Java class private, but we can define a nested class as private. There are two types of nested classes in Java: static and non-static. The static nested class is defined ... Read More

Add Data from Specified Collection to Current Collection in Java

Shriansh Kumar
Updated on 19-Jun-2025 16:01:31

288 Views

In Java, a collection is an object that allows us to group several numbers of objects as a single unit. The Collection interface is the root of the collection framework. We can perform various operations on collection like adding, removing, iterating, searching and retrieving objects. In this article, we will discuss Java programs to add data from the specified collection to the current collection with the help of addAll() method. Using addAll() method of Collection Interface The addAll() method of Collection interface adds data from a specified collection into current collection. It returns a boolean value, which is TRUE if the ... Read More

Add Two Numbers Without Using Arithmetic Operator in Java

Shriansh Kumar
Updated on 19-Jun-2025 15:46:18

4K+ Views

Arithmetic operators such as "+", "-", "*", and "/" are used to perform mathematical operations like addition, subtraction, multiplication, modulo, and division. We have added two numbers using the "+" operator, but in this article, we are going to learn a few Java programs that can add two numbers without using arithmetic operators. The following operators best serve this purpose: Increment operators (++) Bitwise operators ... Read More

Calculate Sum of Two Byte Values Using Type Casting in Java

Shriansh Kumar
Updated on 19-Jun-2025 15:38:06

527 Views

When we convert a data type to another data type, we call it type casting. There are two types of type casting in Java: explicit and implicit. Explicit Type Casting  When we typecast a one datatype to another using the cast operator "()",  it is known as explicit type casting, and it is done manually. We typically use the cast operator to convert a higher datatype to a lower datatype. Therefore, there is a risk of losing data because a lower datatype has a range smaller than a higher datatype. Implicit Type Casting But, to convert a smaller datatype to a larger one, ... Read More

Check Array Bounds While Inputting Elements in Java

Shriansh Kumar
Updated on 19-Jun-2025 14:41:38

157 Views

Array is a linear data structure that is used to store a group of elements with similar data types. It stores data in a sequential manner. Once we create an array, we can't change its size, i.e., it is of fixed length. This article will help you to understand the basic concept of arrays and array bounds in Java. Also, we will discuss Java programs to check array bounds while inputting elements into the array. Array and Array Bound We can access elements of an array by its index. Suppose we have an array of length N, then ... Read More

Advertisements