In this article, we will look at a problem: Given an Input String and a Character, we have to Count the Occurrences of such Character in the given String. For Example, If the Given String is : "Java2Blog" and we have to count the occurrences of Character ‘a’ in the String. 💻 Awesome Tech Resources: […]

In this article, we are going to find first and last digit of a number in Java. To find first and last digit of any number, we can have several ways like using modulo operator or pow() and log() methods of Math class etc. Let’s see some examples. Before moving to example, let’s first create […]

In this article, we are going to learn to find Happy Number using Java. Let’s first understand, what is Happy Number? What is a Happy Number? A number which leaves 1 as a result after a sequence of steps and in each step number is replaced by the sum of squares of its digit. For […]

In this article, we are going to find whether a number is perfect or not using Java. A number is called a perfect number if the sum of its divisors is equal to the number. The sum of divisors excludes the number. There may be several approaches to find the perfect number. For example: 28 […]

In this article, we are going to learn to find Magic Number using Java. Let’s first understand, what is Magic Number? What is a Magic Number? A number which leaves 1 as a result after a sequence of steps and in each step number is replaced by the sum of its digits. For example, if […]