Articles on Trending Technologies

Technical articles with clear explanations and examples

How to Navigate on Path by Button Click in React Router?

Nickey Bricks
Nickey Bricks
Updated on 12-Sep-2024 2K+ Views

React applications often require a convenient method for navigating different routes based on a user's action like clicking a button. However, the biggest hurdle in executing such a task is efficiently executing navigation without reloading the entire page or breaking the single-page application (SPA) experience. This post shows how to efficiently navigate a path by clicking a button in react-router. Prerequisite You are required to have a React development environment by installing Node.js and your preferred code editor. Apart from that, you are also required to install react-router-dom using npm or yarn. Install react-router-dom Module npm install react-router-dom ...

Read More

What are the Essentials of an Effective Cybersecurity Policy?

Pranav Bhardwaj
Pranav Bhardwaj
Updated on 12-Sep-2024 481 Views

A security policy is a document outlining how to defend an organization from dangers, such as computer security threats, and address issues when they arise. A security policy must identify all of a company's assets and all potential threats to those assets. Essentials of a Cybersecurity Policy Institutions develop information security policies for several reasons − To create a complete information security plan. To detect and prevent ...

Read More

Java program to calculate sum of squares of first n natural numbers

AmitDiwan
AmitDiwan
Updated on 11-Sep-2024 1K+ Views

In this article, you will learn to write a program in Java to calculate the sum of squares of first n natural numbers. This program efficiently computes the sum using a mathematical formula − (val * (val + 1) / 2) * (2 * val + 1) / 3 Problem Statement Write a program in Java to calculate the sum of squares of first n natural numbers, where n is a user-defined value. Input val = 8 Output The sum of squares of first 8 natural numbers is204 Steps to calculate sum of squares of first n natural numbers Following are ...

Read More

Java program to set title position

George John
George John
Updated on 11-Sep-2024 2K+ Views

In this article, you'll learn how to position the title of a border in a Java Swing application using the setTitlePosition() method. We'll position the title above the border's top line by utilizing the TitledBorder.ABOVE_TOP constant. This technique is useful for customizing the appearance of your Swing components. To set title position, use the setTitlePosition() method in Java. Let’s say we have to position the title above the border's top line. For that, use the constant ABOVE_TOP for the border − setTitlePosition(TitledBorder.ABOVE_TOP); Steps to set title position Following are the steps to set title position in Java − ...

Read More

Java sql.Time toString() method with example

Vikyath Ram
Vikyath Ram
Updated on 11-Sep-2024 1K+ Views

In this article, you'll learn how to convert a Time object into a String using the toString() method from the java.sql.Time class. This method allows us to easily transform a Time object into its JDBC escape format, which can then be handled as a string. //Retrieving the Time object Time timeObj = rs.getTime("DeliveryTime"); //Converting the Time object to String format String time = timeObj.toString(); Steps for using Java sql.Time toString() Method Following are the steps for using Java sql.Time toString() Method − Create a MySQL table named dispatches. Insert some sample records into ...

Read More

Java program to count set bits in an integer

Shriansh Kumar
Shriansh Kumar
Updated on 11-Sep-2024 3K+ Views

In this article, we are given an integer value and the task is to count the total number of set bits of the given integer. For this task, we need to convert the given value into its corresponding binary representation. The binary number of an integer value is represented as the combination of 0's and 1's. Here, the digit 1 is known as the Set bit in the terms of the computer. Problem Statement Write a program in Java to count set bits in an integer − Input  int num = 10 Output binary representation = 1010 set bit ...

Read More

Java Program to initialize a HashMap with Lambda Expressions

Shriansh Kumar
Shriansh Kumar
Updated on 11-Sep-2024 2K+ Views

Initialization of a Java HashMap means creating an instance of the HashMap class and adding elements to it. The standard way to initialize a HashMap is by using the new keyword. However, we will use the lambda expression in this article. Lambda expressions are methods without any names. It was introduced with the release of Java8. And, HashMap is a class of Java Collection Framework that implements Map Interface. It stores its element in key-value pairs. The Key is an object that is used to retrieve value associated with it. Example 1 The following Java program explains how to initialize ...

Read More

Java program to find the area of a square

Shriansh Kumar
Shriansh Kumar
Updated on 11-Sep-2024 10K+ Views

Given a square whose length of all its sides are l, write a Java program to find its area. A square is a rectangle whose length and breadth are same. Therefore, area of this type of rectangle is the square of its length. To calculate the area of square in Java, you simply need to multiply the given length of square with the length itself and store the result in another variable. Java Program to Find The Area of a Square A Java program that illustrates how to find the area of the square is shown below − public class ...

Read More

Java Program to Print the Months in Different Formats

Saba Hilal
Saba Hilal
Updated on 11-Sep-2024 935 Views

In this article, we are going to use various approaches for formatting the months using different libraries of Java programming language. There are several ways to display months. Sometimes the months are written as numbers, sometimes the months are written in long form or they are written in short forms. Using java.time.Month In this approach, the months are printed by specifying the month number that starts from the number 1. For instance -> Month.of(1) will give JANUARY. Example In this Java program, we are printing all 12 months name. import java.time.Month; public class ShowMonth { ...

Read More

Java program to find smallest of the three numbers using ternary operators

Shriansh Kumar
Shriansh Kumar
Updated on 11-Sep-2024 2K+ Views

To find the smallest from three given numbers using ternary operator, create a temporary variable to store the result of first comparison operation between two numbers. Then, perform second comparison operation between the result of first operation (i.e. temp) and third number to get the final result. Let's understand the problem statement with an example − Example Scenario: Input: nums = 20, 35, 10; Output: res = 10 What is Ternary Operator? The conditional operator in Java is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal ...

Read More
Showing 31921–31930 of 61,297 articles
Advertisements