Check if all the digits of the given number are same | Java program for the above approach ; Function to check if all the digits in the number N is the same or not ; Find the last digit ; Find the current last digit ; Update the value of N ; If there exists any distinct digit , then return No ; Otherwise , return Yes ; Driver Code
import java . io . * ; class GFG { public static String checkSameDigits ( int N ) { int digit = N % 10 ; while ( N != 0 ) { int current_digit = N % 10 ; N = N / 10 ; if ( current_digit != digit ) { return " No " ; } } return " Yes " ; } public static void main ( String args [ ] ) throws IOException { int N = 222 ; System . out . println ( checkSameDigits ( N ) ) ; } }