Check if a number ends with another number or not | Java program for the above approach ; Function to check if B is a suffix of A or not ; Convert numbers into Strings ; Check if s2 is a suffix of s1 or not ; If result is true , print " Yes " ; Driver Code ; Given numbers ; Function Call
import java . util . * ; class GFG { static void checkSuffix ( int A , int B ) { String s1 = String . valueOf ( A ) ; String s2 = String . valueOf ( B ) ; boolean result ; result = s1 . endsWith ( s2 ) ; if ( result ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } public static void main ( String [ ] args ) { int A = 12345 , B = 45 ; checkSuffix ( A , B ) ; } }