Bouncy Number in Java5 May 2025 | 4 min read In this section, we will learn what is a bouncy number and also create Java programs to check if the given number is bouncy. The bouncy number program frequently asked in Java coding tests and academics. Before understanding the bouncy number, first, we will understand what is increasing and decreasing numbers. Increasing NumbersIn an integer traversing from left to right if the current digit is greater than or equal to the previous digit, the number is known as increasing numbers. In other words, we can say that if no digit is exceeded by the digit to its left is called increasing numbers. For example, 1233, 13689, 112334566, etc. Decreasing NumbersIn an integer traversing from left to right if the current digit is less than the previous digit, the number is known as decreasing numbers. In other words, we can say that if no digit is exceeded by the digit to its right is called decreasing numbers. For example, 321, 88531, 8755321, etc. ![]() Let's move to the bouncy number. Bouncy NumberA positive integer that is neither in increasing nor decreasing number is called a bouncy number. It means they bounce between increasing and decreasing. In other words, we can say that if the digits of the number are unsorted. For example, 123742, 101, 43682, etc. We observe that in the given number's digits are neither increasing nor decreasing if we traverse from left to right, hence they are called bouncy numbers. ![]() Note that there is no bouncy number between 1 to 100. The first bouncy number is 101.Steps to Find Bouncy Number
Let's implement the above steps in the Java program and check whether the given number is bouncy or not. Bouncy Number Java ProgramBouncyNumberExample1.java Output 1: ![]() Output 2: ![]() BouncyNumberExample2.java Output 1: ![]() Output 2: ![]() |
Java program to insert a new node at the end of the singly linked list
In this program, we will create a singly linked list and add a new node at the end of the list. To accomplish this task, add a new node after the tail of the list such that tail's will point to the newly added...
4 min read
Split Array Largest Sum in Java
An array numArr[] is given, which only contains the non-negative integers, and an integer sp is also provided. The task is to partition the array into sp continuous subarrays such that the largest sum among these sp subarrays is minimum. Note that subarrays can never be...
19 min read
Java program to insert a new node at the middle of the Doubly Linked List
In this program, we create a doubly linked list and insert a new node in the middle of list. If list is empty, both head and tail will point to new node. If list is not empty, then we will calculate the size of the...
8 min read
How to convert int to long in Java
Java Convert int to long We can convert int to long in java using assignment operator. There is nothing to do extra because lower type can be converted to higher type implicitly. It is also known as implicit type casting or type promotion. Java int to long Example Let's...
1 min read
Java program to check whether two strings are anagram or not
? Two strings are called anagrams if they contain same set of characters but in different order. "keep ? peek", "Mother In Law - Hitler Woman". File: AnagramString .java import java.util.Arrays; public class AnagramString { static void isAnagram(String str1, String str2) { String s1 = str1.replaceAll("\\s", ""); String s2 = str2.replaceAll("\\s", ""); boolean...
1 min read
Java program to create a doubly linked list of n nodes and display it in reverse order
In this program, we create a doubly linked list, and then reverse the list by reversing the direction of the list and print out the nodes. Traverse through the list by swapping the ious pointer with pointer of each node. Then, swap the position of...
6 min read
Java program to determine whether a singly linked list is the palindrome
In this program, we need to check whether given singly linked list is a palindrome or not. A palindromic list is the one which is equivalent to the reverse of itself. The list given in the above figure is a palindrome since it is equivalent to...
7 min read
Java Program to Print Odd and Even Numbers from an array
Java Program to print Odd and Even Numbers from an Array We can print odd and even numbers from an array in java by getting remainder of each element and checking if it is divided by 2 or not. If it is divided by 2, it is...
1 min read
How to convert String to char in Java
Java Convert String to char We can convert String to char in java using charAt() method of String class. The charAt() method returns a single character only. To get all characters, you can use loop. Signature The charAt() method returns a single character of specified index. The signature of charAt()...
2 min read
Java Program to find the transpose of a given matrix
In this program, we need to find the transpose of the given matrix and print the resulting matrix. Transpose of Matrix Transpose of a matrix can be found by interchanging rows with the column that is, rows of the original matrix will become columns of the new...
4 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India





