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
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
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
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
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
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
After JDK version 5, Java introduced the enumeration. It is a group of constants defined using the keyword enum. The final variables in Java are somewhat similar to enumeration. In this article, we will write Java programs in which we define an enum class and try to access all the constants defined in the enum using valueOf() and values() methods. The Java Enum Class We use enum class when we need to define a fixed set of constants. For example, if we want to use the days of the week, planet names, names of all five vowels, etc. Note that all the ... Read More
Array is a linear data structure that is used to store a group of elements with the same data type. We can create an array with primitive datatypes, and since a class is considered a user-defined datatype in Java, it is also possible to create an array of objects. In this article, we are going to discuss object arrays. First of all, let's discuss what is an object array, in Java. What is Object array or Array of Objects An array of objects contains reference variables of objects.We follow the same syntax to create an array of primitives and an array ... Read More
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. When we create an array of two dimensions, i.e., rows and columns, we call it a matrix. In this article, we will create a matrix of M x N and try to rotate it right by K times. Here, M and N are the size of the row and column, respectively. K is the number of times we want to rotate the matrix. Example Scenarios Let's understand what matrix rotation is with the following ... Read More
The given task is to write a Java program that converts an integer into a character. The int and char are primitive datatypes of Java. The int is a 32-bit signed datatype used to store whole numbers, and char holds 16-bit unsigned Unicode characters. The int and char keywords are used to declare an integer variable and a character variable, respectively. We store character variables in a single quotation (' '). Example Scenario To understand the problem statement, let's see an example scenario: Input: int num1 = 83; Output: ch = 'S' Here, num1 is the name of a ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP