In this article, we will learn to create a program to check both horizontal and vertical symmetry in a binary matrix in JavaScript. A binary matrix is a 2-D array that consists of one and zero only as the elements in each cell. Horizontal symmetry of a binary matrix means if the first row is the same as the last row, the second row is the same as the second last row, and so on. What are symmetry matrices? Symmetry in matrices refers to how the values in the matrix mirror themselves along an axis. In the case of a ... Read More
In this article, we will learn to extract the maximum numeric value from a string using Java’s regex. While Java provides several ways to handle string manipulation, regular expressions (regex) offer a powerful and efficient tool for such tasks. Problem Statement The maximum numeric value is extracted from an alphanumeric string. An example of this is given as follows − Input String = abcd657efgh234 Output Maximum numeric value = 657 Using Java Regex and Pattern Class Java provides the Pattern and Matcher classes to work with regular expressions. The Pattern class compiles a regular expression, and the Matcher class is ... Read More
Make CSS Vertical Align Property Work on Element
This article will let you understand the vertical-align property in CSS. Here, we discuss the limitations of the vertical-align property and a few methods to overcome this, and hence, you will learn the solution to make the vertical-align property work on a div tag. Why does vertical-align don't work on div elements? Remember, the `vertical-align` property only works on inline, inline-block, and table-cell elements. You cannot use it to align block-level elements vertically. Tables work differently than divs because all the rows in a table are the same height. If a cell doesn’t have much content, the browser ... Read More
This article will let you understand the vertical-align property in CSS. Here, we discuss the limitations of the vertical-align property and a few methods to overcome this, and hence, you will learn the solution to make the vertical-align property work on a div tag. Why does vertical-align don't work on div elements? Remember, the `vertical-align` property only works on inline, inline-block, and table-cell elements. You cannot use it to align block-level elements vertically. Tables work differently than divs because all the rows in a table are the same height. If a cell doesn’t have much content, the browser ... Read More
Sometimes while working with with dates in JavaScript, it is common to need specific dates for calculations or validations. One such situation is when we are given a date and we have to determine the last day of the previous month. In this article, we are going to learn how we can last day of the Previous Month from Date in Moment.js. Prerequisite Moment.js: Moment.js is a popular JavaScript library used to deal with dates. This library is used to modify, parse, validate, manipulate, and display dates and times in JavaScript. We can install the Moment.js library in ... Read More
In this article, we will learn how to programmatically navigate using React Router. Programmatic navigation enables changing the URL of an application without reloading the page. We can use several approaches to programmatically navigate in a React application using React Router. Approaches to navigate using React Router To programmatically navigate a React application, we can use several methods based on the version of React Router. In React Router v6, the useNavigate hook is introduced, which is recommended for programmatic navigation. By calling the navigate function returned from useNavigate, we can navigate to other routes. In React Router v5, the ... Read More
The final keyword in Java may be employed to define a constant value as well as prevent a variable, method, or class from being changed or overridden. On the other side, immutability describes an object's characteristic of keeping a constant state across the course of its existence. The values of an object don't change after it is formed. Variables, methods, and classes are constrained by the "final" keyword, but immutability goes a step further by guaranteeing that the object's whole state is preserved. Let us learn the key differences between final vs immutability in this article. Final in Java ... Read More
Redirecting is one of the vital features in frontend applications like React apps. Moving from one page to another is known as navigation. In React, navigation is important for maintaining a Single Page Application for a better user experience. react-router-dom is a npm package which enables dynamic routing in react application. In this article, we are going to learn how we can redirect from one page to another in ReactJS. Using React Router Dom Navigating to another page can be done efficiently with the help of react-router-dom. It is an npm package responsible for client-side navigation. Using React ... Read More
Passing data from one component to another is an essential part of building complex React applications. React props and states are fundamental concepts in React. Props stand for properties, which are used for passing data from one component to another, while State is used to manage data within a component. Prerequisites ReactJS Props ReactJS State Passing Data from Child Component to Parent You can easily pass data from a parent component to a child component with the help of props. Passing data from a child component to a ... Read More
To create an Integer object in Java is quite easy. Let us learn about the following two ways for this purpose. Before moving to the coding section, let's briefly discuss the Integer class. The Integer class is a wrapper class in Java, which can be used to encapsulate a primitive int value in an object. Using an Integer Constructor You can create an Integer object using the Integer constructor by passing a primitive int value. In Java, a constructor is a special method whose name is exactly the same as the class name. Example The following example creates an Integer ... Read More
By using pymongo library, we can insert a Python object into MongoDB, which is a widely used MongoDB driver for Python. To insert a Python object represented as a dictionary, we have to establish the setup for a MongoDB client and connect to a database and collection. Before starting, ensure you have installed Python 3 (along with PIP) and MongoDB. The following are the steps for inserting a Python object in MongoDB. Install PyMongo ... Read More