Check whether two strings contain same characters in same order | package whatever do not write package name here ; if length of the b = 0 then we return true ; if length of a = 0 that means b is not present in a so we return false ; Driver code
import java . io . * ; class GFG { public static boolean checkSequence ( String a , String b ) { if ( b . length ( ) == 0 ) return true ; if ( a . length ( ) == 0 ) return false ; if ( a . charAt ( 0 ) == b . charAt ( 0 ) ) return checkSequence ( a . substring ( 1 ) , b . substring ( 1 ) ) ; else return checkSequence ( a . substring ( 1 ) , b ) ; } public static void main ( String [ ] args ) { String s1 = " Geeks " , s2 = " Geks " ; if ( checkSequence ( s1 , s2 ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }