Suppose, I have a vector with following values in it
id = 100
latitude = 2 .33
longitude = 4.55
id = 200
latitude = 1.00
longitude = 3.00
id = 300
latitude = 2.33
longitude = 4.55
and I have following variables
int item = 10;
double x = 2.33;
double y = 4.55
1.) Now, I want to compare the values of 2 variables (x,y) with that of (latitude,Longitude) in the vector.
2.) If (x,y) value is equal to (latitude,Longitude) then I add value of item variable to the vector
My logic to achieve it is as follows
Vector al;
int size = al.size() //need to adjust the size as and when i add/remove items from al
for(int i=0;i<sz-1;i++)
{
if(al.get(i).getClass().equals(Double.TYPE)) //Need to ignore id in Vector
if(a.get(i)==x & a.get(i+1)==y)
{
//add the sensor id at i-2 and adjust the size of vector
}
else {
//remove the items 200,1.00,3.00
// adjust the size of vector
}
But the above code is not giving me expected result.Can anybody provide me with working code to get the final output as follows
10,100,2.33,4.55
10,300,2.33,4.55
Note that contents 200,1.00,3.00 are not present in the expected o/p, 'coz value of (x,y) does not match with (latitude, longitude)
Thanks in advance.