Count number of digits in an integer in Java | Java programming for beginners

preview_player
Показать описание
Java program to count the number of digits in an integer.
Java practice program for beginners.
Java practice program in Strings.
Java practice program in loops.

Example 1:
Input:
n = 100
Output:
3

Example 2:
Input:
n = 1234
Output:
4

Java practice program for ICSE Class 10 Computer Applications students.
Java practice program for ISC Computer Science Class & Class 12 students.
Java tutorial in programming for ISC Computer Science Class & Class 12 students.
Java practice program for AP Computer Science students.

Two approaches used to solve the problem:
1. String method - to convert the int to String and then find the length of the String
2. while loop - count number of digits by removing units digit one by one iteratively

0:00 Intro
0:58 Count digits using the while loop method
4:30 Sample dry run of the Java code to count digits using the while loop method
6:36 Java Code implementation using String method
7:04 Java Code implementation using while loop method

#javaprogramming #iscclass12 #javaforbeginners #iscboardexams #iscboard #computerscienceclass12 #isccomputer #javatutorial #computersciencestudents
Рекомендации по теме