Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-17-2008, 04:37 PM
Member
 
Join Date: Apr 2008
Posts: 33
raj reddy can only hope to improve
please i need the code of comparing these two array lists.
Hi

There were two arraylists


List al1 = (List) classabc.fetchTicketpanel();
System.out.println("THE LATEST VALUES OF THE TICKET KEY1 IS " + al1 );

List al2 = (List) classabc.fetchDrawresults();
System.out.println("THE LATEST VALUES OF THE TICKET KEY2 IS " + al2 );


Think it as a1,a2,a3,a4,a5 are the elements of al1 and b1,b2,b3,b4,b5,b6,b7,b8,b9,b10.........n number of elements

of al2.


how to compare the elements of these two arraylists.

please i need the code of comparing these two array lists.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-17-2008, 04:51 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Mumbai(India)
Posts: 230
sanjeevtarar is on a distinguished road
Hello Raja,

you have already posted this problem then why are you creating duplication.

And other thing is that you have posted again in wrong forum.......IT IS JSP FORUM.



sanjeev
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 04:55 PM
Member
 
Join Date: Apr 2008
Posts: 33
raj reddy can only hope to improve
hi sanjeev

sorry i have not checked

very very sorry sanjeev for that one
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 05:19 PM
Member
 
Join Date: Apr 2008
Posts: 1
harivaram is on a distinguished road
to compare two arraylist
u can use following code to check two arraylists

import java.util.*;
public class Ex {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList al1=new ArrayList();
al1.add("a1");
al1.add("a2");
al1.add("a3");
ArrayList al2=new ArrayList();
al2.add("b1");
al2.add("a2");
al2.add("a3");


if(al1.size()==al2.size()){
Object[] o1=al1.toArray();
Object[] o2=al2.toArray();
if(Arrays.equals(o1,o2)){
System.out.println("Both arraylists are equal");
}else{
System.out.println("Both arraylists are not equal");
}
}
else{
System.out.println("Both arraylists are not equal");
}

}

}
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-18-2008, 07:59 AM
Member
 
Join Date: Apr 2008
Posts: 33
raj reddy can only hope to improve
Hi Harivaram

Thks for your reply

Actually i need to compare the elements of al1,al2.

ie a1,a2,a3,a4,a5 are the elements of al1 and b1,b2,b3,b4,b5,b6,b7,b8,b9,b10.........n number of elements

of al2.

can u give me the code of comparing this two elements of these arraylists

Regards
raja
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-18-2008, 08:42 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,131
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
A simple way I used to test this. See you can get the logic for your application.

Code:
public static void main(String[] args) { // TODO code application logic here ArrayList list1 = new ArrayList(); list1.add("a1"); list1.add("a2"); list1.add("a3"); ArrayList list2 = new ArrayList(); list2.add("b1"); list2.add("a2"); list2.add("a3"); for (int i = 0; i < list1.size(); i++){ String str1 = (String) list1.get(i); for (int j = 0; j < list2.size(); j++){ String str2 = (String) list2.get(j); int result = str1.compareTo(str2); if (result == 0) System.out.println(str1+ " = " + str2); else if (result > 0) System.out.println(str1+ " > " + str2); else if (result < 0) System.out.println(str1+ " < " + str2); } } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best?Vote Now
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 dimensional Lists gapper New To Java 4 01-20-2008 10:01 AM
question about linked lists jkurth Advanced Java 1 11-11-2007 09:33 AM
Tudu Lists 2.1 JavaBean Java Announcements 0 08-10-2007 05:39 PM
Compare lists JavaNoob New To Java 2 08-08-2007 04:11 PM
Tudu Lists 2.0 JavaBean Java Announcements 0 07-11-2007 04:32 PM


All times are GMT +3. The time now is 12:44 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org