Count of sub | Java implementation of the approach ; Function to return the count of possible sub - strings of length n ; Driver code
import java . util . * ; class GFG { static int countSubStr ( String str , int n ) { int len = str . length ( ) ; return ( len - n + 1 ) ; } public static void main ( String args [ ] ) { String str = " geeksforgeeks " ; int n = 5 ; System . out . print ( countSubStr ( str , n ) ) ; } }