I am getting the following error when calling a function from within my class:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1.
Although I used a system prints to see the inputs I am passing in the substring() function and everything seems to be right. The function isContained() returns a boolean value defining whether the substring passed as a parameter is in a list of words. My code is:
for(int i=0; i<=size; i++)
for(int j=i+1; j<=size; j++)
if(isContained(str.substring(i,j-i)))
System.out.println(str.substring(i,j-i));
where size is the size of the string (str) I am passing in the function