I am new to this forum and i am a java beginner . hope u guys'll help me with my problem.
I have an arraylist which has about 10 strings got using result set from the database.
I have another arrayList which has some strings also go from the database.
Now i need to compare these 2 arraylists . If string in list 2 is found in list one i need to display in 1 jsp else in another JSP . Could anybody please help me with this ???
Well... one way to compare two arrayList, or arrays, is, for every element in one of the collection, compare it with all of the elements of the second collection. Once you finish with the first element, continue comparing all the other elements in the first collection, with all the elements in the second collection.
With two arrays, you can use two for. For every element in the first collection, you check out all the elements in the second collection for equals strings. Try to do something like that with your collections. And if you have more question, please ask here :)
Basically you can work around on a loop. As PatoDB says, get an element from one list and compare it with the other whole list elements. Depend on the result (found or not) do the required process. Then move to the next element of the first list and do the same process.