private static boolean validSubstring(String text,int startPos,int len){
  return text != null && startPos + len <= text.length();
}

private static boolean validSubstring ( String text , int startPos , int len ) { return text != null && startPos + len <= text . length ( ) ; }
check whether substring is valid .
