In this video, we explore a slightly less common but essential programming task: extracting digits from a number starting from the first digit and moving to the last. While extracting from last to first is the standard approach, doing it in order requires a bit more mathematical logic.
What you'll learn:
The logic behind extracting digits from left to right.
Two ways to count the number of digits in an integer.
How to use Math.log10() and Math.pow().
A step-by-step Java implementation using a while loop.
Timestamp:
00:00 – More commonly used approach: extracting digits from last to first (covered in another video)
00:20 – Step‑by‑step explanation using pen and paper
01:50 – Discussing the general approach (high‑level overview)
05:08 – How to determine what to divide the number by
08:57 – How to find the number of digits in a given number - two approaches (high‑level)
09:10 – How to find the number of digits in a given number - solution 1 (loop‑based)
10:39 – How to find the number of digits in a given number - solution 2 (math‑based)
14:20 – Discussing the general approach - continued
15:22 – How to find the number of digits in a given number - solution 1 (detailed solution to be covered in the next video)
17:18 – How to compute log 10 in Java (Math.log10)
18:56 – How to find the number of digits using log 10 in Java
20:12 – Pseudocode for the log‑based digit‑count solution
30:29 – Implement the solution in Java
33:55 – THE END
#JavaProgramming #CodingTutorial #ExtractDigits #JavaForBeginners #ProgrammingLogic
Connect with me on LinkedIn: / sagar-k04