Question: Looking for help in JAVA; For my assignment I need to loop through list of words (5757 total) and compare all words with each other.

Looking for help in JAVA;

For my assignment I need to loop through list of words (5757 total) and compare all words with each other.

what i am trying to do: for loop which goes 5757 times for loop which goes from current position in the previous loop, to the current position in the previous loop +10 ( DO 10 times: array[i] to array[i+10], check if arry[i] == arry[i] to i+10 (so check next 10 elements in the array), Simple enough concept, but having so many issues with it

The words are sorted and I make an array with them all, that's not important, checking words isn't an issue for me. Here's where my issue is.

for(int i= 0; i< 5757; i++){ for(int j = i; j < i+10; j++){ 

I want the 2nd for loop to go from CURRENT location in the first for loop (hence j=i) TO i+10 but as you can tell obviously, my issue is that temp ends at 5757 but i checks for i +10... which breaks everything. I'm sorry I'm just really bad at wording this question and I can't figure out how to word this better or how to find answer to this question.

Basically, what I want is this

Check word at position i with word at position i and then 10 following words (hence the 2nd for loop, j = i to i+10. so like this i check words arrayOfWords[i] to arrayOfWords[i+10]

like this i get to check 10 following words for every word

But again, as I said, the issue comes with it going out of bounds by going to i+10... I've no idea how to do this better, or how to word this question better. Pleas help. Thank you in advance for taking your time to answer my horribly worded question.

I hope I explained the question clearly enough.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!