Driver Code
public static void main ( String [ ] args ) { List < String > list = Arrays . asList ( " abab " , " gfg " ) ; for ( String s : list ) { int cnt = countSub ( s ) ; int withEmptyString = cnt + 1 ; System . out . println ( " With ▁ empty ▁ string ▁ count ▁ for ▁ " + s + " ▁ is ▁ " + withEmptyString ) ; System . out . println ( " Without ▁ empty ▁ string ▁ count ▁ for ▁ " + s + " ▁ is ▁ " + cnt ) ; } } }