public int search(String txt){
  int m=pat.length();
  int n=txt.length();
  int i, j;
  for (i=0, j=0; i < n && j < m; i++) {
    j=dfa[txt.charAt(i)][j];
  }
  if (j == m)   return i - m;
  return n;
}

public int search ( String txt ) { int m = pat . length ( ) ; int n = txt . length ( ) ; int i , j ; for ( i = 0 , j = 0 ; i < n && j < m ; i ++ ) { j = dfa [ txt . charAt ( i ) ] [ j ] ; } if ( j == m ) return i - m ; return n ; }
returns the index of the first occurrrence of the pattern string in the text string .
