Last Updated: 09 July, 2022
On this tutorial page we are going to learn how to write a Java program to break an integer into digits. For example, if the input number is 508321 then the program will break the number and display each digit, such as 5, 0, 8, 3, 2, 1 along with their position in the output.
Let's the examples given below.
Example 1: A Java Program to Break an Integer into Digits
Output
Enter any number: 2876313
Digit at the place 7 is: 3
Digit at the place 6 is: 1
Digit at the place 5 is: 3
Digit at the place 4 is: 6
Digit at the place 3 is: 7
Digit at the place 2 is: 8
Digit at the place 1 is: 2
Let's see another program. In the program breaking the number into digits and storing each digit in the array.
Example 2: Break the number into digits and store each digit in an array
Output
2
4
6
8
0
That's all guys, hope this Java Program is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com