Hi I wrote a java code to find longest word made of other words. My logic is to read the list of words from the text file and add each word into an array (In the text the wo
This is the problem:
for(int j1=0;j1
On each iteration through the loop, you're incrementing i1
as well as j1
. i1
could already be at the end of s
, so after you've incremented it, s.charAt(i1)
is going to be invalid.
Two asides:
String.regionMatches