View Single Post
  #5 (permalink)  
Old 04-23-2008, 12:01 PM
raj reddy raj reddy is offline
Member
 
Join Date: Apr 2008
Posts: 30
raj reddy can only hope to improve
Facing Problem With For Loops
Quote:
Originally Posted by raj reddy View Post
how to compare the elements of the two arraylists al1,al2


Let's say we have the following two lists:
al1=[10, 20, 30, 40]
al2=[11, 12, 13, 14, 15,16,17,18,19,20]

(i)we have to compare the first 4 elements of al1 to first 5 elements of al2 10/11,10/12,10/13,10/14,10/15,11,11,11/12,11/13,11/14,11/15,10/11,10/12,10/13,10/14,10/15......................like that all the elements

(ii) and then the same 5 elements of al1 and the next 5 elements of al2

10/16,10/17,10/18,10/19,10/20,11/16,11/17,11/18,11/19,11/20................................................ ..............like
that all the elements

so that we have to compare every element in the first array list, to every five elements at atime in the second arraylist?
can we get this one by using for loops


MY CODE

i have done like this

for (int i=1;i<arrayList2_Length;i++) {

for (int j=1;j<arrayList1_Length; j++) {

if(al2.equals(i)==al1.equals(j))

}

}

CAN YOU MODIFY THIS CODE AND GIVE ME NEW ONE
Reply With Quote