Results 1 to 3 of 3

Thread: hiiii

  1. #1
    aishwarya is offline Member
    Join Date
    Dec 2008
    Posts
    1
    Rep Power
    0

    Red face 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 ???

  2. #2
    PatoDB is offline Member
    Join Date
    Dec 2008
    Posts
    14
    Rep Power
    0

    Default

    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 ::..

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    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

  1. HIIII all :)
    By pheonix in forum Introductions
    Replies: 3
    Last Post: 04-08-2008, 08:17 AM
  2. hiiii all
    By sandeep.kush@gmail.com in forum Introductions
    Replies: 3
    Last Post: 01-03-2008, 07:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •