Does anyone know how to compare contents of two ArrayLists? I want to compare them to see if they match up. Do you have an example or could you point me in the right direction. I know I need to loop through it with an if statement a for loop somehow or both, but I am not sure how. thanks for any help you can provide-
How to Compare Contents of Two Files
Collapse
X
-
Tags: None
-
Originally posted by CodeTilYaDropDoes anyone know how to compare contents of two ArrayLists? I want to compare them to see if they match up. Do you have an example or could you point me in the right direction. I know I need to loop through it with an if statement a for loop somehow or both, but I am not sure how. thanks for any help you can provide-
When you say you want to see if they "match up" you mean if they contain equal objects at the same locations, right?
Then a simple loop going through the ArrayLists should do it. -
It is not that simple. I am trying to compare two separate documents, and find where the changes were made. I want to go through some type of loop to find the changes made on one comparred to the other. The contents may be moved all around.Comment
-
Originally posted by CodeTilYaDropIt is not that simple. I am trying to compare two separate documents, and find where the changes were made. I want to go through some type of loop to find the changes made on one comparred to the other. The contents may be moved all around.Comment
-
-
Originally posted by CodeTilYaDropThey are both text files.Comment
-
I just want to know the word changes of the two documents. Could I use the indexOf in a loop to notice the changes?Comment
-
-
If you use contains, you would be testing to see if it contains what?
To test for word differences, just look word by word in the files and see if the words are the same.
OK Suppose you have the file initially as
Code:this was the file before
Code:was this the file before
Comment
-
I guess I just want to see the word differences for now. Do you know an looping algorithm for this??Comment
-
I am not sure exactly what I need when you put it this way. I will take a look at what I am doing, and see if I can clarify my questions. thanks for trying to help me-Comment
-
You all are great helpers! I really appreciate it!
Can I ask you about one more thing. I was reading about an inner and outer loop to compare items in arrays. Do you know where to find the algorithm for this, too? This might help me too!Comment
Comment