Shriansh Kumar has Published 324 Articles

Java Program to Compare Two Objects

Shriansh Kumar

Shriansh Kumar

Updated on 31-Jul-2024 19:55:42

1K+ Views

To compare objects in Java, check the properties or the hash value of given objects. If the properties of both objects matches, then they are equal. If either property is different, it indicate that the objects are not equal. NOTE: Don't use equality operator (==) to compare objects as it ... Read More

Java program to find the Frequency of a character in a given String

Shriansh Kumar

Shriansh Kumar

Updated on 31-Jul-2024 19:54:06

7K+ Views

For a given a string, write a Java program to find the frequency of a particular character. In Java, String is a datatype that contains one or more characters and is enclosed in double quotes(“ ”). Finding Frequency of a Character in a String To find the Frequency ... Read More

Java Program to Illustrate String Interpolation

Shriansh Kumar

Shriansh Kumar

Updated on 31-Jul-2024 19:53:44

1K+ Views

String interpolation is a concatenation technique used to display output text dynamically or effectively by replacing the placeholder characters with variables (or strings in the subsequent examples). It restructures the code and prevents the need to repeatedly use variables to produce the output. It makes it efficient to write ... Read More

Java program to print prime numbers below 100

Shriansh Kumar

Shriansh Kumar

Updated on 31-Jul-2024 19:53:03

2K+ Views

Any whole number which is greater than 1 and has only two factors i.e. 1 and the number itself, is called a prime number. Other than these two number it has no positive divisor. In this article, we will explain Java programs to print prime numbers between 1 to 100. ... Read More

Java strictfp keyword

Shriansh Kumar

Shriansh Kumar

Updated on 31-Jul-2024 17:27:39

2K+ Views

The strictfp keyword is a modifier that stands for strict floating point. As the name suggests, it ensures that floating-point operations give the same result on any platform. This keyword was introduced in Java version 1.2. In Java, the floating point precision may vary from one platform to another. The ... Read More

Java Program to Print the Elements of an Array

Shriansh Kumar

Shriansh Kumar

Updated on 30-Jul-2024 17:00:39

958 Views

Array is the common way to store similar types of items together in Java. The stored items or values are referred as elements of the array. In this article, we are going to learn how to create an array and print its elements. Printing elements of an array in Java ... Read More

Java program to Print Odd and Even Number from an Array

Shriansh Kumar

Shriansh Kumar

Updated on 30-Jul-2024 16:59:23

2K+ Views

Given an array of type Integer, write a Java program to find the odd and even numbers from that array. Those numbers which are completely divisible by 2 are called even numbers and if a number gives 1 as a remainder on dividing with 2 is known as odd number. ... Read More

Java Program to convert Double to numeric primitive data types

Shriansh Kumar

Shriansh Kumar

Updated on 30-Jul-2024 16:48:08

2K+ Views

Let's say, we have a numeric value of type double and our task is to convert it into other numeric primitive data types. To perform this operation, we require explicit casting as double is the largest primitive datatype available in Java. The process of converting larger data type into smaller ... Read More

Java program to count the number of vowels in a given sentence

Shriansh Kumar

Shriansh Kumar

Updated on 30-Jul-2024 16:45:53

32K+ Views

Given a sentence (string), let's say str, count the total number of vowels in it. In Java, the String is a non-primitive data type which is used to define sequence of characters. And, the English letters a, e, i, o, and u are known as vowels. To count the number ... Read More

Java Program to Compute the Running Total of a List

Shriansh Kumar

Shriansh Kumar

Updated on 30-Jul-2024 16:44:30

1K+ Views

A running total (also known as an accumulated total) of a list represents the sum of a sequence of elements. As new elements are added to the sequence, the running total continuously updates. To perform this operation in Java, we can use for loop and while loop in our program. ... Read More

Advertisements