C:\jexp>java FleschIndex
The extract is:The string tokenizer class allows an application to break a string into tok
ens. Hello.
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of
range: -2
at java.lang.String.charAt(Unknown Source)
at FleschIndex.readabilityIndex(FleschIndex.java:59)
at FleschIndex.main(FleschIndex.java:114)
char endLetter;
// If word.indexOf(" ") = -1
// then word.indexOf(" ")-1 will evaluate to -2.
//endLetter=word.charAt(word.indexOf(" ")-1);
// Try:
endLetter = word.charAt(word.length()-1);