Results 1 to 3 of 3
Thread: hiiii
- 12-25-2008, 07:04 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 1
- Rep Power
- 0
hiiii
Hi guys,
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 ???
- 12-25-2008, 10:10 PM #2
Member
- Join Date
- Dec 2008
- Posts
- 14
- Rep Power
- 0
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 :)..:: abretumundo.wordpress.com ::..
- 12-26-2008, 03:27 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
Similar Threads
-
HIIII all :)
By pheonix in forum IntroductionsReplies: 3Last Post: 04-08-2008, 07:17 AM -
hiiii all
By sandeep.kush@gmail.com in forum IntroductionsReplies: 3Last Post: 01-03-2008, 06:45 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks