Shriansh Kumar has Published 324 Articles

Java Program to Implement the graph data structure

Shriansh Kumar

Shriansh Kumar

Updated on 13-Sep-2024 15:55:37

1K+ Views

A Graph is a non-linear data structure made up of a group of vertices and edges. A vertex or node represent an object, and the connections between them are called edges. In this article, we will understand how to implement the graph data structure in Java. Algorithm ... Read More

Java program to print the factorial of the given number

Shriansh Kumar

Shriansh Kumar

Updated on 13-Sep-2024 15:55:01

5K+ Views

Given a number of type integer, write a Java program to print its factorial. The factorial of a positive integer n is the product of all values from n to 1. For example, the factorial of 3 is (3 * 2 * 1 = 6). Let's understand the problem statement ... Read More

Java program to subtract two matrices

Shriansh Kumar

Shriansh Kumar

Updated on 13-Sep-2024 15:54:00

1K+ Views

For two given matrix each of size m×n, write a Java program to subtract them. The matrix has a row and column arrangement of its elements. A matrix with m rows and n columns can be called as m×n matrix. Individual entries in the matrix are called element and can ... Read More

Java program to check whether a number is positive or negative

Shriansh Kumar

Shriansh Kumar

Updated on 13-Sep-2024 10:23:24

1K+ Views

In this article, we will learn to check whether the number is positive or negative in Java. To check whether the specified number is positive or negative can be determined with respect to 0. A number greater than 0 is considered a positive number whereas a number less than 0 ... Read More

Java program to count set bits in an integer

Shriansh Kumar

Shriansh Kumar

Updated on 11-Sep-2024 11:15:02

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 ... Read More

Java Program to convert LocalDate to java.util.Date

Shriansh Kumar

Shriansh Kumar

Updated on 11-Sep-2024 11:12:58

3K+ Views

Suppose a date is given in LocalDate format, our task is to write a Java program that converts it into java.util.Date. For this problem, we need to add time information to the LocalDate by combining it with a time, such as midnight, or a timezone. Both LocalDate and java.util.Date classes ... Read More

Java Program to initialize a HashMap with Lambda Expressions

Shriansh Kumar

Shriansh Kumar

Updated on 11-Sep-2024 11:08:40

1K+ 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 ... Read More

Java program to find the area of a square

Shriansh Kumar

Shriansh Kumar

Updated on 11-Sep-2024 11:05:11

9K+ 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 ... Read More

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

Shriansh Kumar

Shriansh Kumar

Updated on 11-Sep-2024 11:02:27

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 ... Read More

Java Program to check if the String contains only certain characters

Shriansh Kumar

Shriansh Kumar

Updated on 11-Sep-2024 11:00:41

1K+ Views

For a given string, say "str", write a Java program to check if it contains each character from a specified character array. If it contains print "found" otherwise "not found". A String in Java is a class that represents a contiguous block of characters. Example Scenario: Input 1: String str ... Read More

Advertisements